Index: src/StreamCore.cc =================================================================== RCS file: /afs/psi.ch/user/z/zimoch/.cvsroot/StreamDevice2/src/StreamCore.cc,v retrieving revision 1.35 diff -u -r1.35 StreamCore.cc --- src/StreamCore.cc 15 Sep 2008 09:32:58 -0000 1.35 +++ src/StreamCore.cc 4 Jun 2010 12:11:20 -0000 @@ -1164,14 +1164,21 @@ } if (consumed < 0) { - if (!(flags & AsyncMode) && onMismatch[0] != in_cmd) + if (fmt.flags & default_flag) { - error("%s: Input \"%s%s\" does not match format %%%s\n", - name(), inputLine.expand(consumedInput, 20)(), - inputLine.length()-consumedInput > 20 ? "..." : "", - formatstring); + consumed = 0; + } + else + { + if (!(flags & AsyncMode) && onMismatch[0] != in_cmd) + { + error("%s: Input \"%s%s\" does not match format %%%s\n", + name(), inputLine.expand(consumedInput, 20)(), + inputLine.length()-consumedInput > 20 ? "..." : "", + formatstring); + } + return false; } - return false; } consumedInput += consumed; break; @@ -1321,8 +1328,16 @@ scanLong(fmt, inputLine(consumedInput), value); debug("StreamCore::scanValue(%s, format=%%%c, long) input=\"%s\"\n", name(), fmt.conv, inputLine.expand(consumedInput)()); - if (consumed < 0 || - consumed > inputLine.length()-consumedInput) return -1; + if (consumed < 0) + { + if (fmt.flags & default_flag) + { + value = 0; + consumed = 0; + } + else return -1; + } + if (consumed > inputLine.length()-consumedInput) return -1; debug("StreamCore::scanValue(%s) scanned %li\n", name(), value); flags |= GotValue; @@ -1344,8 +1359,16 @@ scanDouble(fmt, inputLine(consumedInput), value); debug("StreamCore::scanValue(%s, format=%%%c, double) input=\"%s\"\n", name(), fmt.conv, inputLine.expand(consumedInput)()); - if (consumed < 0 || - consumed > inputLine.length()-consumedInput) return -1; + if (consumed < 0) + { + if (fmt.flags & default_flag) + { + value = 0.0; + consumed = 0; + } + else return -1; + } + if (consumed > inputLine.length()-consumedInput) return -1; debug("StreamCore::scanValue(%s) scanned %#g\n", name(), value); flags |= GotValue; @@ -1368,8 +1391,16 @@ scanString(fmt, inputLine(consumedInput), value, maxlen); debug("StreamCore::scanValue(%s, format=%%%c, char*, maxlen=%ld) input=\"%s\"\n", name(), fmt.conv, maxlen, inputLine.expand(consumedInput)()); - if (consumed < 0 || - consumed > inputLine.length()-consumedInput) return -1; + if (consumed < 0) + { + if (fmt.flags & default_flag) + { + value[0] = 0; + consumed = 0; + } + else return -1; + } + if (consumed > inputLine.length()-consumedInput) return -1; #ifndef NO_TEMPORARY debug("StreamCore::scanValue(%s) scanned \"%s\"\n", name(), StreamBuffer(value, maxlen).expand()()); Index: src/StreamFormat.h =================================================================== RCS file: /afs/psi.ch/user/z/zimoch/.cvsroot/StreamDevice2/src/StreamFormat.h,v retrieving revision 1.5 diff -u -r1.5 StreamFormat.h --- src/StreamFormat.h 9 May 2007 13:33:43 -0000 1.5 +++ src/StreamFormat.h 4 Jun 2010 11:45:12 -0000 @@ -23,12 +23,13 @@ #define StreamFormat_h typedef enum { - left_flag = 0x01, - sign_flag = 0x02, - space_flag = 0x04, - alt_flag = 0x08, - zero_flag = 0x10, - skip_flag = 0x20 + left_flag = 0x01, + sign_flag = 0x02, + space_flag = 0x04, + alt_flag = 0x08, + zero_flag = 0x10, + skip_flag = 0x20, + default_flag = 0x40 } StreamFormatFlag; typedef enum { Index: src/StreamFormatConverter.cc =================================================================== RCS file: /afs/psi.ch/user/z/zimoch/.cvsroot/StreamDevice2/src/StreamFormatConverter.cc,v retrieving revision 1.19 diff -u -r1.19 StreamFormatConverter.cc --- src/StreamFormatConverter.cc 7 Oct 2008 09:13:16 -0000 1.19 +++ src/StreamFormatConverter.cc 4 Jun 2010 11:49:12 -0000 @@ -112,7 +112,7 @@ const char* p = source - 1; while (*p != '%' && *p != ')') p--; info.append('%'); - while (++p != source-1) info.append(*p); + while (++p != source-1) if (*p != '?') info.append(*p); } // Standard Long Converter for 'diouxX' Index: src/StreamProtocol.cc =================================================================== RCS file: /afs/psi.ch/user/z/zimoch/.cvsroot/StreamDevice2/src/StreamProtocol.cc,v retrieving revision 1.25 diff -u -r1.25 StreamProtocol.cc --- src/StreamProtocol.cc 5 Feb 2008 09:46:42 -0000 1.25 +++ src/StreamProtocol.cc 4 Jun 2010 11:51:17 -0000 @@ -1504,6 +1504,16 @@ } streamFormat.flags |= skip_flag; break; + case '?': + if (formatType != ScanFormat) + { + errorMsg(line, + "Use of default modifier '?' " + "only allowed in input formats\n"); + return false; + } + streamFormat.flags |= default_flag; + break; default: loop = false; } Index: doc/formats.html =================================================================== RCS file: /afs/psi.ch/user/z/zimoch/.cvsroot/StreamDevice2/doc/formats.html,v retrieving revision 1.17 diff -u -r1.17 formats.html --- doc/formats.html 16 Sep 2008 12:30:08 -0000 1.17 +++ doc/formats.html 4 Jun 2010 13:08:00 -0000 @@ -28,7 +28,7 @@