]> git.ipfire.org Git - thirdparty/HylaFAX.git/commitdiff
Bug 140: don't raise the case of quoted strings
authorLee Howard <faxguy@howardsilvan.com>
Tue, 17 Feb 2004 03:13:59 +0000 (03:13 +0000)
committerLee Howard <faxguy@howardsilvan.com>
Tue, 17 Feb 2004 03:13:59 +0000 (03:13 +0000)
faxd/ClassModem.c++
util/Str.c++
util/Str.h

index 1b9000bdd1d132520f6c54e7be2f0ede2c1e3c51..3dfc2bc7b25e461ba61ae66b903a8206e1592cc2 100644 (file)
@@ -839,7 +839,7 @@ ClassModem::atCmd(const fxStr& cmd, ATResponse r, long ms)
                if (conf.atCmdDelay)
                    pause(conf.atCmdDelay);
                fxStr command = cmd.extract(pos, i-pos);
-               command.raisecase();
+               command.raiseatcmd();
                if (!putModemLine(command))
                    return (false);
                pos = ++i;                      // next segment starts after line break
@@ -871,7 +871,7 @@ ClassModem::atCmd(const fxStr& cmd, ATResponse r, long ms)
                         * translated to \r).
                         */
                        fxStr command = cmd.extract(pos, i-1-pos);
-                       command.raisecase();
+                       command.raiseatcmd();
                        if (!putModemLine(command))
                            return (false);
                        // setup for expected response
@@ -953,7 +953,7 @@ ClassModem::atCmd(const fxStr& cmd, ATResponse r, long ms)
            if (conf.atCmdDelay)
                pause(conf.atCmdDelay);
            fxStr command = cmd.extract(pos, i-pos);
-           command.raisecase();
+           command.raiseatcmd();
            if (!putModemLine(command))
                return (false);
            respPending = true;
index 66d553b21a774f7f736bf7a50fb651f32e1e622e..1db0120daf1dbd0240ddfbc23fe3925a2e868d0d 100644 (file)
@@ -256,6 +256,38 @@ void fxStr::raisecase(u_int posn, u_int chars)
     }
 }
 
+/*
+ * Although T.32 6.1.1 and T.31 6.1 may lead a DCE to not
+ * distinguish between lower case and upper case, many DCEs
+ * actually support lower case characters in quoted strings.
+ * Thus, we don't rasecase quoted strings.
+ */
+void fxStr::raiseatcmd(u_int posn, u_int chars)
+{
+    if (!chars) chars = slength-1-posn;
+    fxAssert(posn+chars<slength, "Str::raiseatcmd: Invalid range");
+    bool quoted = false;
+    while (chars--) {
+#ifdef hpux                            // HPUX bogosity; see above
+#ifdef toupper
+#undef toupper
+#endif
+       if (!quoted)
+           data[posn] = toupper(data[posn]);
+#elif defined(_toupper)
+       char c = data[posn];
+       if (islower(c) && !quoted)
+           data[posn] = _toupper(c);
+#else
+       if (!quoted)
+           data[posn] = toupper(data[posn]);
+#endif
+       if (data[posn] == '\"')
+           quoted = !quoted;
+       posn++;
+    }
+}
+
 fxStr fxStr::copy() const
 {
     return fxStr(data,slength-1);
index 0fc7afd53f1e5f54f0318fee63271d5f4727e2ee..eef970ea1ff30676e56a5026ea485f91b6326cb3 100644 (file)
@@ -162,6 +162,7 @@ public:
     fxStr tail(u_int) const;
     void lowercase(u_int posn=0, u_int len=0);
     void raisecase(u_int posn=0, u_int len=0);
+    void raiseatcmd(u_int posn=0, u_int len=0);
 
     void remove(u_int posn,u_int len=1);