]> andersk Git - moira.git/commitdiff
Only strip whitespace off the end of strings when backing them up.
authorzacheiss <zacheiss>
Fri, 10 Mar 2000 20:55:03 +0000 (20:55 +0000)
committerzacheiss <zacheiss>
Fri, 10 Mar 2000 20:55:03 +0000 (20:55 +0000)
Prevents us from causing duplicate strings in the db when we restore.

backup/db2bkup.awk
backup/dump_db.h
backup/dump_db.pc

index 0f7c28e04d2c8945de2583c8c9821b7f80d4d549..fe1c91b02345c11099075411355146d89557c095 100644 (file)
@@ -87,7 +87,7 @@ NF>=2 {
        for (i = 0; i < count; i++) {
                if (i != 0) print "      dump_sep(f);";
                if (vtype[i] ~ /str/ || vtype[i] ~ /date/) {
-                       printf "      dump_str(f, strtrim(t_%s));\n", vname[i];
+                       printf "      dump_str(f, endtrim(t_%s));\n", vname[i];
                } else {
                        printf "      dump_%s(f, t_%s);\n", vtype[i], vname[i];
                }
index 28b906ff31713606ddc140b57adb8ac1dc40e787..c249eb5f1d60f731e5be222e6e50fb807a7c5b84 100644 (file)
@@ -23,3 +23,4 @@ void punt(char *msg);
 void dbmserr(void);
 void safe_close(FILE *stream);
 FILE *open_file(char *prefix, char *suffix);
+char *endtrim(char *save);
index fda278e89e2062ba4d0c0f6b0bb364722e5efb17..850d01346aa151d05f32f500d248834ef8de5dcc 100644 (file)
@@ -115,3 +115,27 @@ FILE *open_file(char *prefix, char *suffix)
   fprintf(stderr, "Working on %s\n", name);
   return f;
 }
+
+/*
+ * Trim whitespace off the tail end of a string
+ */
+char *endtrim(char *save)
+{
+  char *t, *s;
+
+  s = save;
+  for (t = s; *t; t++)
+    continue;
+  while (t > s)
+    {
+      --t;
+      if (!isspace(*t))
+       {
+         t++;
+         break;
+       }
+    }
+  if (*t)
+    *t = '\0';
+  return s;
+}
This page took 1.097211 seconds and 5 git commands to generate.