]> andersk Git - moira.git/commitdiff
clean up SQL, fixes from QUEL version
authormar <mar>
Mon, 21 Dec 1992 16:40:37 +0000 (16:40 +0000)
committermar <mar>
Mon, 21 Dec 1992 16:40:37 +0000 (16:40 +0000)
gen/letter.dc

index adb9044c54ab7903351aefd62b66e61ce2b0a288..1ab107fdec0b60357efbdf73c2d94d7bc51025b9 100644 (file)
@@ -40,10 +40,11 @@ char **argv;
     EXEC SQL END DECLARE SECTION;
 
 #ifsql INGRES
-    EXEC SQL CONNECT sms;
+    EXEC SQL CONNECT moira;
+    EXEC SQL SET LOCKMODE SESSION WHERE LEVEL=TABLE, READLOCK=SHARED;
 #endsql
 #ifsql INFORMIX
-    EXEC SQL DATABASE sms;
+    EXEC SQL DATABASE moira;
 #endsql
 
     if (argc == 2) {
@@ -71,6 +72,10 @@ char **argv;
 
     init_letter();
 
+    /* The following is declarative, not executed,
+     * and so is dependent on where it is in the file,
+     * not in the order of execution of statements.
+     */
     EXEC SQL WHENEVER SQLERROR GOTO sqlerr;
 
     EXEC SQL SELECT secure INTO :lastrun FROM users WHERE users_id = 0;
@@ -109,6 +114,7 @@ char **argv;
     }
     if (outf)
       fix_file(outf);
+
     exit(MR_SUCCESS);
 
  sqlerr:
@@ -161,7 +167,7 @@ int when;
 {
     register char *p;
     char buf[256], *a1, *a2, *d;
-    char *rindex();
+    char *rindex(), *index();
 
     /* split address into two lines.
      * First determine if postal or interdepartmental address.
@@ -170,27 +176,32 @@ int when;
      */
     strcpy(buf, addr);
     a1 = buf;
-    a2 = rindex(buf, ' ');     /* before state & zip */
-    if (a2 && isupper(a2[1]) && isupper(a2[2]) &&
-       isdigit(a2[3]) && isdigit(a2[4]) && isdigit(a2[5]) &&
-       isdigit(a2[6]) && isdigit(a2[7])) {
-       /* Must be postal address. */
-       /* missing space between state & zip, fix */
-       for (p = a2; *p; p++);          /* find end of string */
-       for (p--; isdigit(*p); p--)
-         p[2] = p[1];
-       p[2] = p[1];
-       p[1] = ' ';
-       /* Backup to previous space, start of state */
-       for (; *a2 != ' '; a2--);
-       /* Backup to previous space, start of city */
-       for (a2--; *a2 != ' '; a2--);
-       /* terminate first line, leave a2 pointing at second */
+    if (a2 = index(buf, '|')) {
        *a2++ = 0;
     } else {
-       /* Must be interdepartmental */
-       a2 = "MIT INTERDEPARTMENTAL MAIL";
+       a2 = rindex(buf, ' ');  /* before state & zip */
+       if (a2 && isupper(a2[1]) && isupper(a2[2]) &&
+           isdigit(a2[3]) && isdigit(a2[4]) && isdigit(a2[5]) &&
+           isdigit(a2[6]) && isdigit(a2[7])) {
+           /* Must be postal address. */
+           /* missing space between state & zip, fix */
+           for (p = a2; *p; p++);              /* find end of string */
+           for (p--; isdigit(*p); p--)
+             p[2] = p[1];
+           p[2] = p[1];
+           p[1] = ' ';
+           /* Backup to previous space, start of state */
+           for (; *a2 != ' '; a2--);
+           /* Backup to previous space, start of city */
+           for (a2--; *a2 != ' '; a2--);
+           /* terminate first line, leave a2 pointing at second */
+           *a2++ = 0;
+       } else {
+           /* Must be interdepartmental */
+           a2 = "MIT INTERDEPARTMENTAL MAIL";
+       }
     }
+
     d = ctime(&when);
     d[strlen(d)-1] = 0;
 
This page took 2.729831 seconds and 5 git commands to generate.