fix problem with comterp string continuation over network connection
[email protected] Fri, 14 Oct 2005 14:05:33 -0700
| Newsgroups | gmane.comp.lib.ivtools.patches |
|---|---|
| Message-ID | <[email protected]> |
--Apple-Mail-3-692878342 Content-Transfer-Encoding: 7bit Content-Type: application/octet-stream; x-unix-mode=0644; name="ivtools-051014-johnston-013" Content-Disposition: attachment; filename=ivtools-051014-johnston-013 Patch: ivtools-051014-johnston-013 For: ivtools-1.2.3 Author: [email protected] Subject: fix problem with comterp string continuation over network connection Requires: This is an intermediate patch to ivtools-1.2.3. To apply, cd to the top-level directory of the ivtools source tree (the directory with src and config subdirs), and apply like this: patch -p0 <ThisFile Summary of Changes: - fix long-standing problem with comterp string continuation (via backslash) when they arrive over a network connection. - start adding support for matching angle-brackets in comterp, as well as support for alternating language syntax (by altering operator table, etc..) on the fly. Index: ComTerp/comhandler.c diff -c ComTerp/comhandler.c:1.2 ComTerp/comhandler.c:1.3 *** ComTerp/comhandler.c:1.2 Tue Oct 4 10:36:38 2005 --- src/ComTerp/comhandler.c Fri Oct 14 13:58:05 2005 *************** *** 1,4 **** --- 1,5 ---- /* + * Copyright (c) 2005 Scott E. Johnston * Copyright (c) 2000 IET Inc. * Copyright (c) 1996 Vectaport Inc. * *************** *** 216,222 **** comterp_->_outfunc = (outfuncptr)&ComTerpServ::fd_fputs; int status = comterp_->ComTerp::run(false /* !once */, false /* !nested */); ! return input_good&&(status==0||status==3) ? 0 : -1; } else { if (inbuf[0]!='\004') cout << inbuf << "\n"; --- 217,223 ---- comterp_->_outfunc = (outfuncptr)&ComTerpServ::fd_fputs; int status = comterp_->ComTerp::run(false /* !once */, false /* !nested */); ! return input_good&&(status==0||status==3||status==2) ? 0 : -1; } else { if (inbuf[0]!='\004') cout << inbuf << "\n"; Index: ComTerp/comterpserv.c diff -c ComTerp/comterpserv.c:1.2 ComTerp/comterpserv.c:1.3 *** ComTerp/comterpserv.c:1.2 Fri Sep 16 11:06:35 2005 --- src/ComTerp/comterpserv.c Fri Oct 14 13:58:05 2005 *************** *** 152,160 **** fbuf.attach(fd); istream in (&fbuf); in.gets(&instr); ! #elif (__GNUC__==3 && __GNUC_MINOR__<1) || __GNUC__>3 char instr[BUFSIZ]; ! FILE* ifptr = fdopen(fd, "r"); fileptr_filebuf fbuf(ifptr, ios_base::in); istream in (&fbuf); in.get(instr, BUFSIZ, '\n'); // needs to be generalized with <vector.h> --- 152,166 ---- fbuf.attach(fd); istream in (&fbuf); in.gets(&instr); ! #elif (__GNUC__==3 && __GNUC_MINOR__<1) char instr[BUFSIZ]; ! FILE* ifptr = fd==0 ? stdin : fdopen(fd, "r"); ! fileptr_filebuf fbuf(ifptr, ios_base::in); ! istream in (&fbuf); ! in.get(instr, BUFSIZ, '\n'); // needs to be generalized with <vector.h> ! #elif __GNUC__>3 ! char instr[BUFSIZ]; ! FILE* ifptr = fd==0 ? stdin : server->handler()->rdfptr(); fileptr_filebuf fbuf(ifptr, ios_base::in); istream in (&fbuf); in.get(instr, BUFSIZ, '\n'); // needs to be generalized with <vector.h> *************** *** 185,192 **** /* append a null byte */ outstr[outpos] = '\0'; ! #if (__GNUC__==3 && __GNUC_MINOR__<1) || __GNUC__>3 ! if (ifptr) fclose(ifptr); #endif return s; --- 191,198 ---- /* append a null byte */ outstr[outpos] = '\0'; ! #if (__GNUC__==3 && __GNUC_MINOR__<1) ! if (ifptr && fd!=0) fclose(ifptr); #endif return s; *************** *** 202,220 **** #if __GNUC__<3 filebuf fbuf; fbuf.attach(fd); ! #elif (__GNUC__==3 && __GNUC_MINOR__<1) || __GNUC__>3 ! FILE* ofptr = fdopen(fd, "w"); fileptr_filebuf fbuf(ofptr, ios_base::out); #else ! fileptr_filebuf fbuf(fd, ios_base::out, false, static_cast<size_t>(BUFSIZ)); #endif ostream out(&fbuf); for (; outpos < bufsize-1 && s[outpos]; outpos++) out.put(s[outpos]); out.flush(); outpos = 0; ! #if (__GNUC__==3 && __GNUC_MINOR__<1) || __GNUC__>3 ! if (ofptr) fclose(ofptr); #endif return 1; } --- 208,229 ---- #if __GNUC__<3 filebuf fbuf; fbuf.attach(fd); ! #elif (__GNUC__==3 && __GNUC_MINOR__<1) ! FILE* ofptr = fd==0 ? stdout : fdopen(fd, "w"); ! fileptr_filebuf fbuf(ofptr, ios_base::out); ! #elif __GNUC__>3 ! FILE* ofptr = fd==0 ? stdout : server->handler()->wrfptr(); fileptr_filebuf fbuf(ofptr, ios_base::out); #else ! fileptr_filebuf fbuf(fd==0?1:fd, ios_base::out, false, static_cast<size_t>(BUFSIZ)); #endif ostream out(&fbuf); for (; outpos < bufsize-1 && s[outpos]; outpos++) out.put(s[outpos]); out.flush(); outpos = 0; ! #if (__GNUC__==3 && __GNUC_MINOR__<1) ! if (ofptr && fd!=0) fclose(ofptr); #endif return 1; } *************** *** 320,327 **** err_print( stderr, "comterp" ); #if __GNUC__<3 filebuf obuf(handler() ? handler()->get_handle() : 1); ! #elif __GNUC__==3 && __GNUC_MINOR__<1 || __GNUC__>3 ! FILE* ofptr = fdopen(handler() ? handler()->get_handle() : 1, "w"); fileptr_filebuf obuf(ofptr, ios_base::out); #else fileptr_filebuf obuf(handler()&&handler()->get_handle()>0 --- 329,339 ---- err_print( stderr, "comterp" ); #if __GNUC__<3 filebuf obuf(handler() ? handler()->get_handle() : 1); ! #elif __GNUC__==3 && __GNUC_MINOR__<1 ! FILE* ofptr = handler() ? fdopen(handler()->get_handle(), "w") : stdout; ! fileptr_filebuf obuf(ofptr, ios_base::out); ! #elif __GNUC__>3 ! FILE* ofptr = handler() ? handler()->wrfptr() : stdout; fileptr_filebuf obuf(ofptr, ios_base::out); #else fileptr_filebuf obuf(handler()&&handler()->get_handle()>0 *************** *** 330,337 **** #endif ostream ostr(&obuf); ostr.flush(); ! #if __GNUC__==3 && __GNUC_MINOR__<1 || __GNUC__>3 ! if (ofptr) fclose(ofptr); #endif status = -1; } else if (quitflag()) { --- 342,349 ---- #endif ostream ostr(&obuf); ostr.flush(); ! #if __GNUC__==3 && __GNUC_MINOR__<1 ! if (ofptr && handler()) fclose(ofptr); #endif status = -1; } else if (quitflag()) { *************** *** 345,352 **** err_print( stderr, "comterp" ); #if __GNUC__<3 filebuf obuf(handler() ? handler()->get_handle() : 1); ! #elif __GNUC__==3 && __GNUC_MINOR__<1 || __GNUC__>3 ! FILE* ofptr = fdopen(handler() ? handler()->get_handle() : 1, "w"); fileptr_filebuf obuf(ofptr, ios_base::out); #else fileptr_filebuf obuf(handler()&&handler()->get_handle()>0 --- 357,367 ---- err_print( stderr, "comterp" ); #if __GNUC__<3 filebuf obuf(handler() ? handler()->get_handle() : 1); ! #elif __GNUC__==3 && __GNUC_MINOR__<1 ! FILE* ofptr = handler() ? fdopen(handler()->get_handle(), "w") : stdout; ! fileptr_filebuf obuf(ofptr, ios_base::out); ! #elif __GNUC__>3 ! FILE* ofptr = handler() ? handler()->wrfptr() : stdout; fileptr_filebuf obuf(ofptr, ios_base::out); #else fileptr_filebuf obuf(handler()&&handler()->get_handle()>0 *************** *** 356,363 **** #endif ostream ostr(&obuf); ostr.flush(); ! #if __GNUC__==3 && __GNUC_MINOR__<1 || __GNUC__>3 ! if (ofptr) fclose(ofptr); #endif status = -1; } --- 371,378 ---- #endif ostream ostr(&obuf); ostr.flush(); ! #if __GNUC__==3 && __GNUC_MINOR__<1 ! if (ofptr && handler()) fclose(ofptr); #endif status = -1; } Index: ComUtil/_lexscan.c diff -c ComUtil/_lexscan.c:1.1 ComUtil/_lexscan.c:1.2 *** ComUtil/_lexscan.c:1.1 Tue Jun 15 08:53:26 2004 --- src/ComUtil/_lexscan.c Fri Oct 14 13:58:03 2005 *************** *** 176,183 **** /* Initialize */ *toktype = TOK_NONE; - *toklen = 0; *tokstart = 0; token_state = token_state_save; token_state_save = TOK_WHITESPACE; --- 176,186 ---- /* Initialize */ *toktype = TOK_NONE; *tokstart = 0; + if (token_state_save != TOK_STRING) + *toklen = 0; + else + *toklen = strlen(token); token_state = token_state_save; token_state_save = TOK_WHITESPACE; *************** *** 305,312 **** *bufptr = 0; CURR_CHAR = buffer[0]; if (CURR_CHAR == '\0') { ! if (token_state == TOK_COMMENT) token_state_save = token_state; *linenum--; return FUNCOK; } --- 308,317 ---- *bufptr = 0; CURR_CHAR = buffer[0]; if (CURR_CHAR == '\0') { ! if (token_state == TOK_COMMENT || token_state == TOK_STRING) { token_state_save = token_state; + token[*toklen] = '\0'; + } *linenum--; return FUNCOK; } Index: ComUtil/_parser.c diff -c ComUtil/_parser.c:1.2 ComUtil/_parser.c:1.3 *** ComUtil/_parser.c:1.2 Tue Oct 4 10:36:36 2005 --- src/ComUtil/_parser.c Fri Oct 14 13:58:03 2005 *************** *** 1,4 **** --- 1,5 ---- /* + * Copyright (c) 2005 Scott E. Johnston * Copyright (c) 1993-1995 Vectaport Inc. * Copyright (c) 1989 Triple Vision, Inc. * *************** *** 164,171 **** errid = ERR_UNEXPECTED_RPAREN;\ else if( toktype == TOK_RBRACKET )\ errid = ERR_UNEXPECTED_RBRACKET;\ ! else\ errid = ERR_UNEXPECTED_RBRACE;\ COMERR_SET1( errid, *linenum );\ goto error_return;} --- 165,174 ---- errid = ERR_UNEXPECTED_RPAREN;\ else if( toktype == TOK_RBRACKET )\ errid = ERR_UNEXPECTED_RBRACKET;\ ! else if( toktype == TOK_RBRACE )\ errid = ERR_UNEXPECTED_RBRACE;\ + else\ + errid = ERR_UNEXPECTED_RANGBRACK;\ COMERR_SET1( errid, *linenum );\ goto error_return;} *************** *** 175,192 **** errid = ERR_UNEXPECTED_LPAREN;\ else if( toktype == TOK_LBRACKET )\ errid = ERR_UNEXPECTED_LBRACKET;\ ! else\ errid = ERR_UNEXPECTED_LBRACE;\ COMERR_SET1( errid, *linenum );\ goto error_return;} #define INSTACK_PRIORITY_HIGHER( incoming_priority ) rkg_instack( incoming_priority) #define LEFT_PAREN( toktype ) \ ! (toktype == TOK_LPAREN || toktype == TOK_LBRACKET || toktype == TOK_LBRACE) #define RIGHT_PAREN( toktype ) \ ! (toktype == TOK_RPAREN || toktype == TOK_RBRACKET || toktype == TOK_RBRACE) #define PROCEEDING_WHITESPACE( tokstart ) \ (tokstart == 0 || isspace( buffer[tokstart-1] )) --- 178,197 ---- errid = ERR_UNEXPECTED_LPAREN;\ else if( toktype == TOK_LBRACKET )\ errid = ERR_UNEXPECTED_LBRACKET;\ ! else if( toktype == TOK_LBRACE )\ errid = ERR_UNEXPECTED_LBRACE;\ + else\ + errid = ERR_UNEXPECTED_LANGBRACK;\ COMERR_SET1( errid, *linenum );\ goto error_return;} #define INSTACK_PRIORITY_HIGHER( incoming_priority ) rkg_instack( incoming_priority) #define LEFT_PAREN( toktype ) \ ! (toktype == TOK_LPAREN || toktype == TOK_LBRACKET || toktype == TOK_LBRACE || toktype == TOK_LANGBRACK) #define RIGHT_PAREN( toktype ) \ ! (toktype == TOK_RPAREN || toktype == TOK_RBRACKET || toktype == TOK_RBRACE || toktype == TOK_LANGBRACK) #define PROCEEDING_WHITESPACE( tokstart ) \ (tokstart == 0 || isspace( buffer[tokstart-1] )) *************** *** 1010,1016 **** if( expecting == OPTYPE_BINARY ) { if( !PROCEEDING_WHITESPACE( tokstart ) || UNEXPECTED_NEW_EXPRESSION ) { ! UNEXPECTED_LPAREN_ERROR( tokstart ); } /* End of an argument */ --- 1015,1021 ---- if( expecting == OPTYPE_BINARY ) { if( !PROCEEDING_WHITESPACE( tokstart ) || UNEXPECTED_NEW_EXPRESSION ) { ! UNEXPECTED_LPAREN_ERROR( toktype ); } /* End of an argument */ Index: ComUtil/_scanner.c diff -c ComUtil/_scanner.c:1.1 ComUtil/_scanner.c:1.2 *** ComUtil/_scanner.c:1.1 Tue Jun 15 08:53:26 2004 --- src/ComUtil/_scanner.c Fri Oct 14 13:58:03 2005 *************** *** 40,45 **** --- 40,46 ---- #include "comterp.ci" + int _angle_brackets = 0; /*! *************** *** 106,111 **** --- 107,114 ---- TOK_RBRACKET Right bracket TOK_LBRACE Left brace TOK_RBRACE Right brace + TOK_LANGBRACK Left angle bracket + TOK_RANGBRACK Right angle bracket TOK_KEYWORD Keyword for free format parameters, i.e. ":SIZE" TOK_IDENTIFIER Identifier, i.e. command name TOK_OPERATOR Operator *************** *** 193,198 **** --- 196,211 ---- search_state = LOOK_DONE; break; + case '<' : + if (_angle_brackets) *toktype = TOK_LANGBRACK; + search_state = LOOK_DONE; + break; + + case '>' : + if (_angle_brackets) *toktype = TOK_RANGBRACK; + search_state = LOOK_DONE; + break; + case ':' : if( isident( buffer[*bufptr] )) search_state = LOOK_KEYWORD; Index: ComUtil/comterp.arg diff -c ComUtil/comterp.arg:1.1 ComUtil/comterp.arg:1.2 *** ComUtil/comterp.arg:1.1 Tue Jun 15 08:53:26 2004 --- src/ComUtil/comterp.arg Fri Oct 14 13:58:03 2005 *************** *** 28,33 **** --- 28,43 ---- int opr_tbl_default(); int opr_tbl_opstr(unsigned commid); int opr_tbl_topstr(); + void* opr_tbl_ptr_get(); + void opr_tbl_ptr_set(void* ptr); + unsigned opr_tbl_numop_get(); + void opr_tbl_numop_set(unsigned numop); + unsigned opr_tbl_maxop_get(); + void opr_tbl_maxop_set(unsigned maxop); + unsigned opr_tbl_maxpri_get(); + void opr_tbl_maxpri_set(unsigned maxpri); + int opr_tbl_lastop_get(); + void opr_tbl_lastop_set(int lastop); /* PARSER.C */ #ifdef __cplusplus int parser(void *infile,char *(*infunc)(char*,int,void*), Index: ComUtil/comterp.err diff -c ComUtil/comterp.err:1.1 ComUtil/comterp.err:1.2 *** ComUtil/comterp.err:1.1 Tue Jun 15 08:53:26 2004 --- src/ComUtil/comterp.err Fri Oct 14 13:58:03 2005 *************** *** 142,147 **** --- 142,153 ---- #define ERR_UNEXPECTED_LBRACE 1311 /* "parser: (%d) Unexpected left brace" */ + #define ERR_UNEXPECTED_RANGBRACK 1312 + /* "parser: (%d) Unexpected right angle bracket" */ + + #define ERR_UNEXPECTED_LANGBRACK 1313 + /* "parser: (%d) Unexpected left angle bracket" */ + #define ERR_TYPE_BADPARAMS 5201 /* "types: Bad parameters in function call" */ Index: ComUtil/comterp.h diff -c ComUtil/comterp.h:1.2 ComUtil/comterp.h:1.3 *** ComUtil/comterp.h:1.2 Fri Sep 9 10:58:16 2005 --- src/ComUtil/comterp.h Fri Oct 14 13:58:03 2005 *************** *** 43,54 **** #define TOK_RBRACKET 19 /* Right bracket */ #define TOK_LBRACE 20 /* Left brace */ #define TOK_RBRACE 21 /* Right brace */ ! #define TOK_KEYWORD 22 /* Keyword for free format parameters */ /* Token types returned from OPTABLE.C */ ! #define TOK_COMMAND 23 /* Command name */ ! #define TOK_BLANK 24 /* generated by empty parens: () */ /* OPTABLE.C Constants */ --- 43,56 ---- #define TOK_RBRACKET 19 /* Right bracket */ #define TOK_LBRACE 20 /* Left brace */ #define TOK_RBRACE 21 /* Right brace */ ! #define TOK_LANGBRACK 22 /* left angle bracket (less than) */ ! #define TOK_RANGBRACK 23 /* right angle bracket (greater than) */ ! #define TOK_KEYWORD 24 /* Keyword for free format parameters */ /* Token types returned from OPTABLE.C */ ! #define TOK_COMMAND 25 /* Command name */ ! #define TOK_BLANK 26 /* generated by empty parens: () */ /* OPTABLE.C Constants */ Index: ComUtil/optable.c diff -c ComUtil/optable.c:1.1 ComUtil/optable.c:1.2 *** ComUtil/optable.c:1.1 Tue Jun 15 08:53:26 2004 --- src/ComUtil/optable.c Fri Oct 14 13:58:03 2005 *************** *** 65,70 **** --- 65,81 ---- /* Minimum can always be considered zero */ static int last_operid = -1; + void* opr_tbl_ptr_get() { return (void*)OperatorTable; } + void opr_tbl_ptr_set(void* ptr) { OperatorTable = ptr; } + unsigned opr_tbl_numop_get() { return NumOperators; } + void opr_tbl_numop_set(unsigned numop) { NumOperators = numop; } + unsigned opr_tbl_maxop_get() { return MaxOperators; } + void opr_tbl_maxop_set(unsigned maxop) { MaxOperators = maxop; } + unsigned opr_tbl_maxpri_get() { return MaxPriority; } + void opr_tbl_maxpri_set(unsigned maxpri) { MaxPriority = maxpri; } + int opr_tbl_lastop_get() { return last_operid; } + void opr_tbl_lastop_set(int lastop) { last_operid = lastop; } + #define OPSTR( index ) (symbol_pntr(OperatorTable[index].operid)) #define OPSTR_LEN( index ) (symbol_len(OperatorTable[index].operid)) #define COMMAND( index ) (symbol_pntr(OperatorTable[index].commid)) *************** *** 1046,1053 **** { return last_operid; } - - - - - --- 1057,1059 ---- Index: config_ivtools/params.def diff -c config_ivtools/params.def:1.6 config_ivtools/params.def:1.7 *** config_ivtools/params.def:1.6 Fri Oct 7 11:10:20 2005 --- config/params.def Fri Oct 14 13:58:23 2005 *************** *** 467,473 **** #ifndef AceCCDefines #ifdef AceDir ! #define AceCCDefines -DHAVE_ACE -DACE_MT_SAFE=0 #else #define AceCCDefines /**/ #endif --- 467,473 ---- #ifndef AceCCDefines #ifdef AceDir ! #define AceCCDefines -DHAVE_ACE /* -DACE_MT_SAFE=0 */ #else #define AceCCDefines /**/ #endif Index: include_std/Imakefile diff -c include_std/Imakefile:1.1 include_std/Imakefile:1.2 *** include_std/Imakefile:1.1 Tue Jun 15 08:57:54 2004 --- src/include/ivstd/Imakefile Fri Oct 14 13:58:20 2005 *************** *** 7,10 **** --- 7,11 ---- IvmkcmTargets($(PACKAGE)) InstallIncludes(ivstd) + InstallInclude(ivstd,iosfwd) Index: top_ivtools/configure diff -c top_ivtools/configure:1.2 top_ivtools/configure:1.3 *** top_ivtools/configure:1.2 Thu Oct 6 12:26:49 2005 --- ./configure Fri Oct 14 13:58:00 2005 *************** *** 779,784 **** --- 779,791 ---- Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] + _ACEOF + fi + + if test -n "$ac_init_help"; then + + cat <<\_ACEOF + Optional Features: --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] *** /dev/null Fri Oct 14 13:58:24 PDT 2005 --- patches/ivtools-051014-johnston-013 *************** patches/ivtools-051014-johnston-013 *** 0 **** --- 1 ---- + ivtools-051014-johnston-013 --Apple-Mail-3-692878342-- ------------------------------------------------------- This SF.Net email is sponsored by: Power Architecture Resource Center: Free content, downloads, discussions, and more. http://solutions.newsforge.com/ibmarch.tmpl