escape backslash
[m6w6/ext-psi] / m4 / psi_const.m4
index cea747e518928233f8a3f9f2ea12967560fe0175..900b536e6d437b8362292c07a6263459364883c7 100644 (file)
@@ -1,12 +1,24 @@
-# add_str_const(name, value)
-add_str_const() {
-       PSI_CONSTS="{PSI_T_STRING, \"string\", \"psi\\\\$1\", $2, PSI_T_QUOTED_STRING}, $PSI_CONSTS"
+# psi_add_str_const(name, value)
+# Add a pre-defined string constant to $PSI_CONSTS
+psi_add_str_const() {
+       grep -q "\"psi\\\\\\\\$1\"" $PSI_CONSTS \
+               || cat >>$PSI_CONSTS <<EOF
+       {PSI_T_STRING, "string", "psi\\$1", $2, PSI_T_QUOTED_STRING},
+EOF 
 }
-# add_int_const(name, value)
-add_int_const() {
-       PSI_CONSTS="{PSI_T_INT, \"int\", \"psi\\\\$1\", \"$2\", PSI_T_NUMBER}, $PSI_CONSTS"
+
+# psi_add_int_const(name, value)
+# Add a pre-defined int constant to $PSI_CONSTS
+psi_add_int_const() {
+       grep -q "\"psi\\\\\\\\$1\"" $PSI_CONSTS \
+               || cat >>$PSI_CONSTS <<EOF
+       {PSI_T_INT, "int", "psi\\\\$1", "$2", PSI_T_NUMBER}, 
+EOF
 }
+
 dnl PSI_CONST(const name, type)
+dnl Check the value of a str/int constant and add it to the list of pre-defined
+dnl constants.
 AC_DEFUN(PSI_CONST, [
        AC_CACHE_CHECK(value of $1, psi_cv_const_$1, [
                psi_const_val=
@@ -29,10 +41,10 @@ AC_DEFUN(PSI_CONST, [
        then
                case $2 in
                str*)
-                       add_str_const "$1" "$psi_cv_const_$1"
+                       psi_add_str_const "$1" "$psi_cv_const_$1"
                        ;;
                int)
-                       add_int_const "$1" "$psi_cv_const_$1"
+                       psi_add_int_const "$1" "$psi_cv_const_$1"
                        ;;
                esac
        fi