message: add the alarm and handle the newline in #if
diff: @@ -105,6 +105,7 @@ BEFORE="before" # Store the main header and the #ifdef/#define of header file
  HAS_HIP_RUNTIME="false"
  DURING_LICENSE="false"
  INCLUDE_REGEX="^#include.*"
  +INCLUDE_INC="\.inc"
  MAIN_PART_MATCH="$(get_include_regex $1)"
  HEADER_DEF=$(get_header_def $1)
  IFNDEF=""
  @@ -118,7 +119,8 @@ ENDIF_REX="^#endif"
  IN_IF="false"
  KEEP_LINES=0
  LAST_NONEMPTY=""
  -
  +ALARM=""
  +COMMENT_REGEX="^ *(\/\/|\/\*)"
  while IFS='' read -r line || [ -n "$line" ]; do
  if [ "${line}" = '#include "hip/hip_runtime.h"' ] && [ "${SKIP}" = "true" ]; then
  @@ -150,18 +152,29 @@ while IFS='' read -r line || [ -n "$line" ]; do
  IN_IF="false"
  fi
  SKIP="false"
  + if [ -z "${ALARM}" ]; then
  + ALARM="set"
  + fi
  elif [ ! -z "${MAIN_PART_MATCH}" ] && [[ "${line}" =~ ${MAIN_PART_MATCH} ]]; then
  line="$(convert_header ${line})"
  echo "${line}" >> ${BEFORE}
  else
  - if [[ "${line}" =~ $INCLUDE_REGEX ]]; then
  + if [ -z "${ALARM}" ] && [[ "${line}" =~ $COMMENT_REGEX ]]; then
  + ALARM="set"
  + elif [[ "${line}" =~ $INCLUDE_REGEX ]]; then
  line="$(convert_header ${line})"
  + if [[ ! "${line}" =~ $INCLUDE_INC ]] && [ "${ALARM}" = "set" ]; then
  + ALARM="true"
  + fi
  fi
  echo "${line}" >> "${CONTENT}"
  SKIP="false"
  fi
  fi
  done < $1
  +if [ "${ALARM}" = "true" ]; then
  + echo "ALARM $1 may not be sorted correctly"
  +fi
  echo "/*${GINKGO_LICENSE_BEACON}" > $1
  cat LICENSE >> $1
  echo "${GINKGO_LICENSE_BEACON}*/" >> $1
  @@ -221,17 +234,7 @@ if [ -f "${CONTENT}" ]; then
  PREV_INC=0
  IN_IF="false"
  while IFS='' read -r line; do
  - if [[ "${line}" =~ $IF_REX ]] || [ "$IN_IF" = "true" ]; then
  - # make sure that the header in #if is not extracted
  - echo "${line}" >> $1
  - IN_IF="true"
  - if [[ "${line}" =~ $ENDIF_REX ]]; then
  - IN_IF="false"
  - # To keep the original lines
  - PREV_INC=-3
  - fi
  - else
  - if [[ ${line} =~ ${INCLUDE_REGEX} ]]; then
  + if [[ ${line} =~ ${INCLUDE_REGEX} ]] && [[ ! ${line} =~ ${INCLUDE_INC} ]]; then
  if [[ ${PREV_INC} == 1 ]]; then
  echo "" >> $1
  fi
  @@ -245,7 +248,6 @@ if [ -f "${CONTENT}" ]; then
  fi
  fi
  echo "${line}" >> $1
  - fi
  done < ${CONTENT}
  rm ${CONTENT}
  fi
  \ No newline at end of file
  