<commit_before>################################################################################
# Macro definitions for some simple CMake utility functions.
################################################################################

################################################################################
# Functions for list operations.
################################################################################

MACRO(SORT var_name list)
  # Sort the given list and store it in var_name.
  
  # should be the following 2 lines, but SORT is documented
  # but not implemented in cmake 2.4.3
  # SET(${var_name} ${list})
  # LIST(SORT ${var_name})
  
  SET(sort_tmp1 "")
  FOREACH(l ${list})
    SET(sort_inserted 0)
    SET(sort_tmp2 "")
    FOREACH(l1 ${sort_tmp1})
      IF("${l}" STRLESS "${l1}" AND ${sort_inserted} EQUAL 0)
        SET(sort_tmp2 ${sort_tmp2} "${l}" "${l1}")
        SET(sort_inserted 1)
      ELSE("${l}" STRLESS "${l1}" AND ${sort_inserted} EQUAL 0)
        SET(sort_tmp2 ${sort_tmp2} "${l1}")
      ENDIF("${l}" STRLESS "${l1}" AND ${sort_inserted} EQUAL 0)
    ENDFOREACH(l1)
    IF(${sort_inserted} EQUAL 0)
      SET(sort_tmp1 ${sort_tmp1} "${l}")
    ELSE(${sort_inserted} EQUAL 0)
      SET(sort_tmp1 ${sort_tmp2})
    ENDIF(${sort_inserted} EQUAL 0)
  ENDFOREACH(l)
  SET(${var_name} ${sort_tmp1})
ENDMACRO(SORT)

MACRO(UNIQUE var_name list)
  # Make the given list have only one instance of each unique element and
  # store it in var_name.
  SET(unique_tmp "")
  FOREACH(l ${list})
    IF(NOT "${unique_tmp}" MATCHES "(^|;)${l}(;|$)")
      SET(unique_tmp ${unique_tmp} ${l})
    ENDIF(NOT "${unique_tmp}" MATCHES "(^|;)${l}(;|$)")
  ENDFOREACH(l)
  SET(${var_name} ${unique_tmp})
ENDMACRO(UNIQUE)

MACRO(INTERSECTION var_name list1 list2)
  # Store the intersection between the two given lists in var_name.
  SET(intersect_tmp "")
  FOREACH(l ${list1})
    IF("${list2}" MATCHES "(^|;)${l}(;|$)")
      SET(intersect_tmp ${intersect_tmp} ${l})
    ENDIF("${list2}" MATCHES "(^|;)${l}(;|$)")
  ENDFOREACH(l)
  SET(${var_name} ${intersect_tmp})
ENDMACRO(INTERSECTION)

MACRO(REMOVE var_name list1 list2)
  # Remove elements in list2 from list1 and store the result in var_name.
  SET(${var_name} ${list1})
  LIST(REMOVE_ITEM ${var_name} list1 ${list2})
ENDMACRO(REMOVE)


################################################################################
# Simple arithmetic.
################################################################################

MACRO(INCREMENT var_name input)
  # Increment the input variable and store the result in var_name.
  MATH(EXPR ${var_name} "${input} - 1")
ENDMACRO(INCREMENT)
<commit_msg>BUG: INCREMENT() macro decrements the value<commit_after>################################################################################
# Macro definitions for some simple CMake utility functions.
################################################################################

################################################################################
# Functions for list operations.
################################################################################

MACRO(SORT var_name list)
  # Sort the given list and store it in var_name.
  
  # should be the following 2 lines, but SORT is documented
  # but not implemented in cmake 2.4.3
  # SET(${var_name} ${list})
  # LIST(SORT ${var_name})
  
  SET(sort_tmp1 "")
  FOREACH(l ${list})
    SET(sort_inserted 0)
    SET(sort_tmp2 "")
    FOREACH(l1 ${sort_tmp1})
      IF("${l}" STRLESS "${l1}" AND ${sort_inserted} EQUAL 0)
        SET(sort_tmp2 ${sort_tmp2} "${l}" "${l1}")
        SET(sort_inserted 1)
      ELSE("${l}" STRLESS "${l1}" AND ${sort_inserted} EQUAL 0)
        SET(sort_tmp2 ${sort_tmp2} "${l1}")
      ENDIF("${l}" STRLESS "${l1}" AND ${sort_inserted} EQUAL 0)
    ENDFOREACH(l1)
    IF(${sort_inserted} EQUAL 0)
      SET(sort_tmp1 ${sort_tmp1} "${l}")
    ELSE(${sort_inserted} EQUAL 0)
      SET(sort_tmp1 ${sort_tmp2})
    ENDIF(${sort_inserted} EQUAL 0)
  ENDFOREACH(l)
  SET(${var_name} ${sort_tmp1})
ENDMACRO(SORT)

MACRO(UNIQUE var_name list)
  # Make the given list have only one instance of each unique element and
  # store it in var_name.
  SET(unique_tmp "")
  FOREACH(l ${list})
    IF(NOT "${unique_tmp}" MATCHES "(^|;)${l}(;|$)")
      SET(unique_tmp ${unique_tmp} ${l})
    ENDIF(NOT "${unique_tmp}" MATCHES "(^|;)${l}(;|$)")
  ENDFOREACH(l)
  SET(${var_name} ${unique_tmp})
ENDMACRO(UNIQUE)

MACRO(INTERSECTION var_name list1 list2)
  # Store the intersection between the two given lists in var_name.
  SET(intersect_tmp "")
  FOREACH(l ${list1})
    IF("${list2}" MATCHES "(^|;)${l}(;|$)")
      SET(intersect_tmp ${intersect_tmp} ${l})
    ENDIF("${list2}" MATCHES "(^|;)${l}(;|$)")
  ENDFOREACH(l)
  SET(${var_name} ${intersect_tmp})
ENDMACRO(INTERSECTION)

MACRO(REMOVE var_name list1 list2)
  # Remove elements in list2 from list1 and store the result in var_name.
  SET(${var_name} ${list1})
  LIST(REMOVE_ITEM ${var_name} list1 ${list2})
ENDMACRO(REMOVE)


################################################################################
# Simple arithmetic.
################################################################################

MACRO(INCREMENT var_name input)
  # Increment the input variable and store the result in var_name.
  MATH(EXPR ${var_name} "${input} + 1")
ENDMACRO(INCREMENT)

{'fraction_non_alphanumeric': 0.3133580705009276, 'fraction_numerical': 0.0163265306122449, 'mean_word_length': 5.364817001180637, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4929194', 'n_tokens_mistral': 1845, 'n_tokens_neox': 1744, 'n_words': 431}