static VOID eqck_idstrip(char *idname, char *stripid ) { register char *cp = idname; if (*cp == '"') /* Get rid of starting double quote */ CMnext(cp); /* Get rid of embedded double quotes */ while (*cp) { if (*cp == '"') { if (*(cp+1) == '"') /* Skip escaped embedded quotes */ CMnext(cp); if (*(cp+1) == '\0') /* Skip last quote */ { *stripid = '\0'; break; } } CMcpyinc(cp, stripid); } if (*stripid != '\0') *stripid = '\0'; }
/*{ ** Name: cus_trmwhite - Trim trailing white space. ** ** Description: ** Used by the parser facility for trimming trailing white space ** in character texts residing in memory. The text may be null terminated ** but doesn't have to be. This is the reason why the length argument ** is passed along with the buffer pointer. This routine is currently ** only used in calls to psf_error to make text presented to recipients ** of error messages more user friendly. ** ** Inputs: ** len Max length to be scanned for white space ** bufp Pointer to the buf holding char data ** (does not have to be null terminated) ** Outputs: ** Returns: ** Length Length of non-white part of the string ** ** Exceptions: ** None. ** ** Side Effects: ** None. ** ** History: ** 11-apr-87 (stec) ** written ** 16-apr-87 (stec) ** changed a little. ** Addressed performance and Kanji issues. ** 02-may-1990 (fred) ** Revamped to trim trailing white space from an arbitrary string. ** Previously, it was assumed that trailing white space started ** with the first bit o' white space from the beginning. The routine ** will now trim from the end back. This was necessitated for BLOB ** support which is the first case of a datatype name with an embedded ** blank (standard name - 'long varchar'). ** 25-mar-93 (rickh) ** Moved here from PSFTRMWH.C and renamed with a cuf prefix. */ i4 cus_trmwhite( u_i4 len, char *bufp) { register char *ep; /* pointer to end of buffer (one beyond) */ register char *p; register char *save_p; if (!bufp) { return (0); } p = bufp; save_p = p; ep = p + (int)len; for (; (p < ep) && (*p != EOS); ) { if (!CMwhite(p)) save_p = CMnext(p); else CMnext(p); } return ((i4)(save_p - bufp)); }
/* ** Name: gwsxa_rightTrimBlank - trim blanks off tails of a (possibly non-terminated) ** string. ** ** Description: ** This routine walks through a (possibly non-NULL-terminated) string ** up to maxlen bytes looking for last non-space character. It then ** steps over that character and replaces the ensuing space with a NULL. ** ** This function differs from gwsxa_zapblank() above in that it will ** allow embeded spaces to remain within the string. ** ** Returns: ** Nothing. ** ** History: ** 04-Dec-2008 (coomi01) b121323 ** Created */ VOID gwsxa_rightTrimBlank(char *str, i4 maxlen) { char *notBlankPtr; char *currPtr; char *endPtr; /* ** If passed an empty string then just return */ if (!str || (maxlen<=0) ) return; /* ** Init the pointers */ currPtr = str; endPtr = &str[maxlen]; notBlankPtr = NULL; /* ** Careful, The string maybe dbyte */ while ( currPtr < endPtr ) { if ( (*currPtr != EOS) && !CMspace(currPtr) ) { /* Save non-space position */ notBlankPtr = currPtr; } /* ** Step forward */ CMnext(currPtr); } if ( NULL != notBlankPtr ) { /* ** Step foward, over last non-blank */ CMnext(notBlankPtr); /* ** But do not write beyound buffer end */ if (notBlankPtr < endPtr) { *notBlankPtr = EOS; } } else { /* ** String entirely composed of spaces */ *str = EOS; } }
/* * regtry - try match at specific point */ static bool /* 0 failure, 1 success */ regtry(RE_EXP *prog, char *string) { register i4 i; register char **sp; register char **ep; reginput = string; regstartp = prog->startp; regendp = prog->endp; sp = prog->startp; ep = prog->endp; for (i = NSUBEXP; i > 0; i--) { *sp = NULL; # ifndef DOUBLEBYTE CMnext( *sp ); # else sp++; # endif /* #ifndef DOUBLEBYTE */ *ep = NULL; # ifndef DOUBLEBYTE CMnext( *ep ); # else ep++; # endif /* #ifndef DOUBLEBYTE */ } if (regmatch(prog->program + 1)) { prog->startp[0] = string; prog->endp[0] = reginput; return( TRUE ); } else return( FALSE ); }
size_t STtrmnwhite_DB( char *string, size_t max_len) { register char *p = string; register char *nw = p; register char *end = p + max_len; /* ** after the loop, nw points to the first character beyond ** the last non-white character. Done this way because you ** can't reverse scan a string with CM efficiently */ while (p < end && *p != EOS) { if (!CMwhite(p)) { CMnext(p); nw = p; } else CMnext(p); } { register size_t nwl = nw - string; if (nwl < max_len) *nw = EOS; return nwl; } }
STATUS s_srem_set() { char *s; char *send; i4 pos; i4 n; char short_remark[OOSHORTREMSIZE+1]; if (St_sr_given) { s_error(0x3A8, NONFATAL, NULL); s_cmd_skip(); return FAIL; } if (Cact_ren == NULL) { s_error(0x38A, FATAL, NULL); } St_sr_given = TRUE; Tokchar++; while (CMspace(Tokchar) || *Tokchar == '\t') { CMnext(Tokchar); } s = short_remark; send = s + OOSHORTREMSIZE; while (*Tokchar != '\n' && *Tokchar != EOS) { if (s <= send-CMbytecnt(Tokchar)) { if (*Tokchar == '\t') { /* if tab, replace it with the one blank */ *s = ' '; s++; Tokchar++; } else { CMcpyinc(Tokchar, s); } } else { CMnext(Tokchar); } } *s = EOS; Cact_ren->ren_shortrem = STalloc(short_remark); return OK; }
static i4 yylex( FILE *input ) { char *pscan; if( yygetline( input ) != OK ) return( tEOF ); /* Unless the -C flag was specified, blank out all of the comments */ pscan = infile->yytext; while (pass_comments == FALSE && *pscan != EOS) { if (infile->yycomment == TRUE) { /* Look for the 'end comment' identifier */ if (STbcompare(pscan,2,ERx("*/"),2,FALSE) == 0) { /* Blank out the 'end comment' characters */ CMcpychar(ERx(" "), pscan); CMnext(pscan); CMcpychar(ERx(" "), pscan); /* Remember that the comment has ended */ infile->yycomment = FALSE; } /* Blank out non-whitespace characters of the comment */ else if (!CMwhite(pscan)) { CMcpychar(ERx(" "), pscan); } /* Whitespace chars are skipped, this lets \n thru */ } /* Look for the 'begin comment' identifier */ else if (STbcompare(pscan,2,ERx("/*"),2,FALSE) == 0) { /* Blank out the 'begin comment' characters */ CMcpychar(ERx(" "), pscan); CMnext(pscan); CMcpychar(ERx(" "), pscan); infile->yycomment = TRUE; } CMnext(pscan); /* Continue the scan with the next character */ } if( is_history(infile->yytext ) == OK) { return( tHISTORY ); } if( *infile->yytext == '#' ) return( tDIRECTIVE ); return( tSOURCE ); }
static void yyputline( char *outtext) { char token_buf[MAX_LINE+1]; char token_val[MAX_LINE+1]; char *p = token_buf; static char *symc = ERx( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_$"); i4 symc_l = STlength(symc); i4 defidx; static i4 iterate_level = 0; /* Check to make sure we don't have runaway recursion */ if (iterate_level++ > MAX_ITERATION) { SIfprintf( stderr, E_YAPP006 ); yydump(); } /* Break up the string into tokens and try to resolve symbols */ while (*outtext != EOS) { p = token_buf; while (STindex(symc, outtext, symc_l) != NULL) { STlcopy(outtext, p, 1); CMnext(outtext); CMnext(p); } /* Found a token that may be defined as a symbol */ if (p != token_buf) { /* If the token is defined then translate the */ /* value of the substituted text, otherwise just */ /* output the untranslated text. */ STcopy(ERx(""), p); if (OK == is_defined(token_buf, token_val)) yyputline( token_val ); else SIprintf("%s", token_buf); } /* The text being processed at this point is whitespace, */ /* operators, or some other characters that are not */ /* valid for tokens. */ else { SIputc(*outtext, stdout); CMnext(outtext); } } iterate_level--; }
/* ** Name: Disp_Form ** ** Decription: ** Disposition: form-data; recevied with no filename. Implies a page ** variable name. ** Extract the variable and store it in the upload structure for use ** later. ** ** Inputs: ** sess ice session structure ** line pointer to the current line ** linelen length of the line ** ** Outputs: ** pos number of characters handled. ** ** Return: ** GSTAT_OK success ** other failure ** ** History: ** 23-Oct-98 (fanra01) ** Created. */ static GSTATUS Disp_Form (WTS_SESSION* sess, char* line, i4 linelen, i4 * pos) { GSTATUS err = GSTAT_OK; PWTS_UPLOAD load= sess->load; char* p = line + *pos; char* varname; i4 remain = linelen - *pos; i4 i = 0; i4 j = 0; if (STbcompare ("name", 4, p, 0, TRUE) == 0) { /* ** Find the first quote after name */ while ((*p != '\"') && (i < remain)) { CMbyteinc(i,p); CMnext(p); } CMbyteinc(i,p); /* skip the quote */ CMnext(p); varname= p; while ((*p != '\"') && (i < remain)) { j+=CMbytecnt(p); CMbyteinc(i,p); CMnext(p); } CMbyteinc(i,p); /* skip the quote */ CMnext(p); /* ** Allocate space for the variable name a '=' character and an EOS */ if ((err = GAlloc (&load->varname, j+2, FALSE)) == GSTAT_OK) { MEfill (j+2, 0, load->varname); MECOPY_VAR_MACRO (varname, j, load->varname); STcat (load->varname, "="); } *pos += i; load->state = US_VAL; } else { HandlerException (sess, line, linelen, pos); } return (err); }
static uchar lookup(char *opname) { i4 opn; uchar rtn = opNONE; /* ** If there's an "=<value>" following the flag, point argval at the value, ** and then replace the "=" with an EOS... */ if (NULL != (argval = STindex(opname, ERx("="), 0))) { *argval = EOS; CMnext(argval); if (*argval == EOS) return opNONE; } /* Look up the flag in the table... */ for (opn = 0; opn < NUM_OPT; opn++) { if (!STbcompare(opname,99,option[opn].op_text,99,FALSE)) { if (rtn == opNONE) /* First candidate we've found? */ rtn = option[opn].op_id; else return opNONE; /* Not unique, apparently. */ } } return rtn; }
char * STrindex_DB( const char *str, const char *mstr, register size_t len) { char *where = NULL; if (len <= 0) len = MAXI2; while (len > 0 && *str != '\0') { if (CMcmpcase(str, mstr) == 0) where = (char *)str; CMbytedec(len, str); CMnext(str); } if (where != NULL && *where != '\0') return (where); else return (NULL); }
static VOID eqck_idschar(char *idname ) { register char *cp = idname; if (*cp == '_') /* Check if first char is an underscore */ { er_write (E_EQ0515_FIPS_IDCHAR, EQ_WARN, 1, idname); return; } /* Check for special characters anywhere in the identifier */ while (*cp) { /* ** Check for special characters anywhere or for an underscore as ** the last character. */ if (*cp == '$' || *cp == '@' || *cp == '#' || (*cp == '_' && *(cp+1) == '\0')) { er_write (E_EQ0515_FIPS_IDCHAR, EQ_WARN, 1, idname); break; } CMnext(cp); } }
/* ** Name: FWrite_Fenc ** ** Decription: ** An encoding description for the following file. Stored for use in ** the furture. ** ** Inputs: ** sess ice session structure ** line pointer to the current line ** linelen length of the line ** ** Outputs: ** pos number of characters handled. ** ** Return: ** GSTAT_OK success ** other failure ** ** History: ** 23-Oct-98 (fanra01) ** Created. */ static GSTATUS FParm_Fenc (WTS_SESSION* sess, char* line, i4 linelen, i4 * pos) { GSTATUS err = GSTAT_OK; PWTS_UPLOAD load= sess->load; i4 remain = linelen - *pos; char* p = line + *pos; char* enc = NULL; i4 i=0; if ((err = GAlloc (&enc, remain + 1, FALSE)) == GSTAT_OK) { load->encode = enc; while (CMwhite(p)) { CMbyteinc(i,p); CMnext(p); } while (i < remain) { CMbyteinc(i,p); CMcpyinc (p, enc); } load->state = US_FPARM; } *pos += i; return (err); }
/* ** Name: File_Mime ** ** Decription: ** The mime type of the following file. Extracted an saved for use in ** in the future. ** ** Inputs: ** sess ice session structure ** line pointer to the current line ** linelen length of the line ** ** Outputs: ** pos number of characters handled. ** ** Return: ** GSTAT_OK success ** other failure ** ** History: ** 23-Oct-98 (fanra01) ** Created. */ static GSTATUS File_Mime (WTS_SESSION* sess, char* line, i4 linelen, i4 * pos) { GSTATUS err = GSTAT_OK; PWTS_UPLOAD load= sess->load; i4 remain = linelen - *pos; char* p = line + *pos; char* mime = NULL; i4 i=0; if ((err = GAlloc (&mime, remain + 1, FALSE)) == GSTAT_OK) { load->type = mime; while ((remain > 0) && CMwhite(p)) { CMbyteinc(i,p); CMnext(p); } while (i < remain) { CMbyteinc(i,p); CMcpyinc (p, mime); } load->state = US_FPARM; } *pos += i; return (err); }
/* ** Name: check_path_chars - test path characters are supported. ** ** Description: ** Test that the characters in the path are permitted. ** ** Inputs: ** loc Pointer to location structure containing path. ** ** Outputs: ** status More detailed error code for failure. ** ** Returns: ** result OK No invalid characters found. ** FAIL Invalid characters found in path. ** ** History: ** 14-Feb-2005 (fanra01) ** Create to replace call to LOisvalid. ** 03-Jun-2005 (drivi01) ** Replaced Window's portion of check_path_chars ** with LOisvalid. ** 11-Jul-2005 (fanra01) ** Add status output. */ static i4 check_path_chars( LOCATION* loc, STATUS* status ) { i4 result = OK; char dev[MAX_LOC]; char path[MAX_LOC]; char file[MAX_LOC]; char ext[MAX_LOC]; char vers[MAX_LOC]; char *p; # if defined(NT_GENERIC) if (!LOisvalid( loc, &result )) { if (status != NULL) { *status = result; } return FAIL; } # else /* NT_GENERIC */ if (LOdetail( loc, dev, path, file, ext, vers ) != OK) return FAIL; for (p = path; *p != EOS; CMnext(p)) { if (!(CMalpha(p) || CMdigit(p) || CMcmpnocase(p, PATH_SEPARATOR) || '_' || *p == ' ')) return FAIL; } for (p = file; *p != EOS; CMnext(p)) { if (!(CMalpha(p) || CMdigit(p) || *p == '_' || *p == ' ')) return FAIL; } for (p = ext; *p != EOS; CMnext(p)) { if (!(CMalpha(p) || CMdigit(p) || *p == '_' || *p == ' ')) return FAIL; } # endif /* NT_GENERIC */ return(result); }
/* ** Get the next character: ** It does not modify the parameter 'lpcText' */ char PeekNextChar (const char* lpcText) { char* pch = (char*)lpcText; if (!pch) return '\0'; CMnext(pch); if (!pch) return '\0'; return *pch; }
/*{ ** Name: RPgetwords - parse a string into words ** ** Description: ** RPgetwords() is similar to the CL STgetwords(), but allows ** for the specification of word delimiters. Consecutive word ** delimiters in the parse string result in blank words. The character ** that follows the last non-white space character of each word is ** replaced by the EOS character. ** ** Inputs: ** delims - pointer to string of delimiters ** string - pointer to string to be parsed ** wordcount - size of 'wordarray' ** ** Outputs: ** wordcount - number of words found ** wordarray - array of character pointers holding starting address ** of each word. ** ** Returns: ** none ** ** Side effects: ** Words in 'string' are terminated with EOS. **/ void RPgetwords( char *delims, char *string, i4 *wordcount, char **wordarray) { i4 count = 0; char **org; char *p; org = wordarray; while (count < *wordcount) { *wordarray++ = string; ++count; p = string; while (*string != EOS && STindex(delims, string, 0) == NULL) { if (!CMwhite(string)) p = string; CMnext(string); } if (p < string && !CMwhite(p)) CMnext(p); if (*string == EOS) { *p = EOS; break; } *p = EOS; CMnext(string); } if (count < *wordcount) org[count] = NULL; *wordcount = count; }
/* * regpiece - something followed by possible [*+?] * * Note that the branching code sequences used for ? and the general cases * of * and + are somewhat optimized: they use the same NOTHING node as * both the endmarker for their branch list and the body of the last branch. * It might seem that this node could be dispensed with entirely, but the * endmarker role is not redundant. */ static char * regpiece(i4 *flagp) { register char *ret; register char op; register char *next; i4 flags; ret = regatom(&flags); if (ret == NULL) return(NULL); op = *regparse; if (!ISMULT(op)) { *flagp = flags; return(ret); } if (!(flags&HASWIDTH) && op != '?') _FAIL("*+ operand could be empty"); *flagp = (op != '+') ? (WORST|SPSTART) : (WORST|HASWIDTH); if (op == '*' && (flags&SIMPLE)) reginsert(STAR, ret); else if (op == '*') { /* Emit x* as (x&|), where & means "self". */ reginsert(BRANCH, ret); /* Either x */ regoptail(ret, regnode(BACK)); /* and loop */ regoptail(ret, ret); /* back */ regtail(ret, regnode(BRANCH)); /* or */ regtail(ret, regnode(NOTHING)); /* null. */ } else if (op == '+' && (flags&SIMPLE)) reginsert(PLUS, ret); else if (op == '+') { /* Emit x+ as x(&|), where & means "self". */ next = regnode(BRANCH); /* Either */ regtail(ret, next); regtail(regnode(BACK), ret); /* loop back */ regtail(next, regnode(BRANCH)); /* or */ regtail(ret, regnode(NOTHING)); /* null. */ } else if (op == '?') { /* Emit x? as (x|) */ reginsert(BRANCH, ret); /* Either x */ regtail(ret, regnode(BRANCH)); /* or */ next = regnode(NOTHING); /* null. */ regtail(ret, next); regoptail(ret, next); } CMnext( regparse ); if (ISMULT(*regparse)) _FAIL("nested *?+"); return(ret); }
/* * regrepeat - repeatedly match something simple, report how many */ static i4 regrepeat(char *p) { register i4 count = 0; register char *scan; register char *opnd; scan = reginput; opnd = OPERAND(p); switch (OP(p)) { case ANY: count = STlength(scan); scan += count; break; case EXACTLY: while (*opnd == *scan) { CMbyteinc( count, scan ); CMnext( scan ); } break; case ANYOF: while (*scan != '\0' && STchr(opnd, *scan) != NULL) { CMbyteinc( count, scan ); CMnext( scan ); } break; case ANYBUT: while (*scan != '\0' && STchr(opnd, *scan) == NULL) { CMbyteinc( count, scan ); CMnext( scan ); } break; default: /* Oh dear. Called inappropriately. */ _error("internal foulup"); count = 0; /* Best compromise. */ break; } reginput = scan; return(count); }
/* * regc - emit (if appropriate) a byte of code */ static void regc( char *b ) { if (regcode != ®dummy) { CMcpychar( b, regcode ); CMnext( regcode ); } else # ifndef DOUBLEBYTE regsize++; # else CMbyteinc(regsize, b); # endif /* #ifndef DOUBLEBYTE */ }
static int __inline IsBefore(char *p1 ,char *p2) { char *p; if (!p1 || !p2) return 0; for (p=p1; *p ; CMnext(p)) { if (_istalpha (*p)) { p1=p; break; } } for (p=p2; *p ; CMnext(p)) { if (_istalpha (*p)) { p2=p; break; } } return (_tcsicmp (p1,p2)<0); }
void main(int argc, char *argv[]) { char buf[ 4096 ]; LPSTR lpCmdLine; char *startquote; char *endquote; STprintf(buf, ERx( "iiabf abf" )); lpCmdLine = GetCommandLine(); /* ** The current executable could have been invoked with the ** executable name in quotes. If that is the case, skip ** over the quotes before looking for the arguments. */ lpCmdLine = STskipblank( lpCmdLine, STlength(lpCmdLine) ); if ( *lpCmdLine == '"' ) { startquote = lpCmdLine; CMnext( startquote ); if ( (endquote = STindex( startquote, "\"", 0 )) != NULL ) { CMnext( endquote ); lpCmdLine = endquote; } } if ( lpCmdLine = STindex(lpCmdLine, " ", 0) ) STcat(buf, lpCmdLine); if ( execute(buf) != OK ) PCexit(FAIL); PCexit(OK); }
int ExtractValue (char* pToken, int nKeyLen, char* szValue) { int nEqual = 0; char* pItem = &pToken[nKeyLen]; szValue[0] = '\0'; if (pItem) { if (pItem[0] == '=') { nEqual = 1; CMnext(pItem); STcopy (pItem, szValue); } } return nEqual; }
char *FIND_SEPstring(char *token,char *string) { i4 token_len ; i4 string_len ; char *cp = NULL ; char *pp = NULL ; char *tp = NULL ; if (token == NULL || *token == EOS) { if (tracing&TRACE_PARM) SIfprintf(traceptr,ERx("FIND_SEPstring> token is null\n")); return (NULL); } if (string == NULL || *string == EOS) { if (tracing&TRACE_PARM) SIfprintf(traceptr,ERx("FIND_SEPstring> string is null\n")); return (NULL); } string_len = STlength(string); if ((token_len = STlength(token)) < string_len) { if (tracing&TRACE_PARM) SIfprintf(traceptr ,ERx("FIND_SEPstring> token <%s> is too small (%d chars)\n") ,token,token_len); return (NULL); } for (tp = token, cp = NULL, pp = NULL ; (*tp != EOS)&&(cp == NULL)&&(token_len-- >= string_len) ; CMnext(tp)) { if ((STbcompare(tp, string_len, string, string_len, TRUE) == 0) &&((pp == NULL)||CMoper(pp)||CMwhite(pp))) { cp = tp; } pp = tp; } return (cp); }
static bool apply_list( bool (*proc) (char *, bool) ) { char *featname, *featnext; bool only; char savechar; bool rtn = TRUE; /* ** Flag whether there's only one package in the list. Some of the ** processing functions care. */ only = (NULL == STindex(featlist, ERx(","), 0)); /* Loop through each feature name in the list... */ for (featname = featlist; featname && *featname;) { /* Find the next one, and make sure current one is EOS-terminated... */ featnext = STindex(featname, ERx(","), 0); if (featnext != NULL) { savechar = *featnext; *featnext = EOS; } /* Call the processing routine... */ if (!(*proc)(featname,only)) rtn = FALSE; /* Onward through the fog... */ if (featnext == NULL) break; *(featname = featnext) = savechar; CMnext(featname); } return rtn; }
STATUS create_canon_fe(SEPFILE *res_ptr) { STATUS ret_val = OK ; /* if OK, refresh FE screen */ char do_com_result ; #ifdef VMS if (SEPtcsubs < 4) PCsleep(1000); #endif show_cursor(); do_com_result = do_comments(); append_line(OPEN_CANON,1); switch (do_com_result) { case 'R': case 'r': append_sepfile(res_ptr); break; case 'E': case 'e': break; case 'I': case 'i': append_line(SKIP_SYMBOL,1); break; } append_line(CLOSE_CANON,1); kfe_ptr = kfebuffer; /* reset counter for key buffer */ if (canonAns == EOS) { disp_prompt(NULLSTR,NULL,NULL); /* erase prompt */ } else { CMnext(kfe_ptr); ret_val = FAIL; /* don't refresh FE screen */ } return (ret_val); }
/* ** Name: gwsxa_zapblank - trim blanks off a (possibly non-terminated) ** string. ** ** Description: ** This routine walks through a (possibly non-NULL-terminated) string ** up to maxlen bytes looking for a space. It replaces the space with ** a NULL value. The use of this function is primarily to convert ** a blank-padded string to a regular NULL-terminated string for ** error reporting. ** ** Returns: ** Nothing. ** ** History: ** 14-sep-92 (robf) ** Created */ VOID gwsxa_zapblank(char *str,i4 maxlen) { i4 i; /* ** If passed an empty string then just return */ if (!str) return; for( i=0; i<maxlen; i++) { if(CMspace(str)) break; CMnext(str); } if( i!=maxlen) *str= EOS; }
char * STindex_DB( const char *str, const char *mstr, size_t len) { if (str == NULL || mstr == NULL) return (NULL); if (len <= 0) len = 32767; while (len > 0 && *str != '\0') { if (CMcmpcase(str, mstr) == 0) return ((char *)str); CMbytedec(len, str); CMnext(str); } return (NULL); }
/*{ ** Name: mktimestamp - make time stamp ** ** Description: ** Convert the system specific time string (from TMstr) into a ** Replicator timestamp of the form dd-mmm-yyy hh:mm:ss. ** mktimestamp() is only intended as a temporary fix to the problem ** regarding availablity of TMbreak(). ** ** Inputs: ** timestr ** ** Outputs: ** timestamp ** ** Returns: ** none */ static void mktimestamp( char *timestr, char *timestamp) { char *tmwords[MAX_TMWORDS]; char *dom; char *mon; char *yr; char *hms; i4 count; *timestamp = EOS; count = MAX_TMWORDS; # ifdef VMS if CMspace(timestr) CMnext(timestr); RPgetwords(ERx(" -"), timestr, &count, tmwords); if (count < 3) return; dom = tmwords[0]; mon = tmwords[1]; yr = tmwords[2]; hms = tmwords[3]; # else STgetwords(timestr, &count, tmwords); if (count < 5) return; mon = tmwords[1]; dom = tmwords[2]; hms = tmwords[3]; yr = tmwords[4]; # endif STprintf(timestamp, ERx("%.2s-%.3s-%.4s %.8s"), dom, mon, yr, hms); }
/* * regmatch - main matching routine * * Conceptually the strategy is simple: check to see whether the current * node matches, call self recursively to see whether the rest matches, * and then act accordingly. In practice we make some effort to avoid * recursion, in particular by going through "ordinary" nodes (that don't * need to know whether the rest of the match failed) by a loop instead of * by recursion. */ static i4 /* 0 failure, 1 success */ regmatch(char *prog) { register char *scan; /* Current node. */ char *next; /* Next node. */ scan = prog; #ifdef xDEBUG if (scan != NULL && regnarrate) SIfprintf(stderr, "%s(\n", regprop(scan)); #endif while (scan != NULL) { #ifdef xDEBUG if (regnarrate) SIfprintf(stderr, "%s...\n", regprop(scan)); #endif next = regnext(scan); switch (OP(scan)) { case BOL: if (reginput != regbol) return(0); break; case EOL: if (*reginput != '\0') return(0); break; case ANY: if (*reginput == '\0') return(0); CMnext( reginput ); break; case EXACTLY: { register i4 len; register char *opnd; opnd = OPERAND(scan); /* Inline the first character, for speed. */ if (*opnd != *reginput) return(0); len = STlength(opnd); if (len > 1 && STncmp( opnd, reginput, len ) != 0 ) return(0); reginput += len; } break; case ANYOF: if (*reginput == '\0' || STchr(OPERAND(scan), *reginput) == NULL ) return(0); CMnext( reginput ); break; case ANYBUT: if (*reginput == '\0' || STchr(OPERAND(scan), *reginput) != NULL ) return(0); CMnext( reginput ); break; case NOTHING: break; case BACK: break; case OPEN+1: case OPEN+2: case OPEN+3: case OPEN+4: case OPEN+5: case OPEN+6: case OPEN+7: case OPEN+8: case OPEN+9: { register i4 no; register char *save; no = OP(scan) - OPEN; save = reginput; if (regmatch(next)) { /* * Don't set startp if some later * invocation of the same parentheses * already has. */ if (regstartp[no] == NULL) regstartp[no] = save; return(1); } else return(0); } break; case CLOSE+1: case CLOSE+2: case CLOSE+3: case CLOSE+4: case CLOSE+5: case CLOSE+6: case CLOSE+7: case CLOSE+8: case CLOSE+9: { register i4 no; register char *save; no = OP(scan) - CLOSE; save = reginput; if (regmatch(next)) { /* * Don't set endp if some later * invocation of the same parentheses * already has. */ if (regendp[no] == NULL) regendp[no] = save; return(1); } else return(0); } break; case BRANCH: { register char *save; if (OP(next) != BRANCH) /* No choice. */ next = OPERAND(scan); /* Avoid recursion. */ else { do { save = reginput; if (regmatch(OPERAND(scan))) return(1); reginput = save; scan = regnext(scan); } while (scan != NULL && OP(scan) == BRANCH); return(0); /* NOTREACHED */ } } break; case STAR: case PLUS: { register char nextch; register i4 no; register char *save; register i4 minx; /* * Lookahead to avoid useless match attempts * when we know what character comes next. */ nextch = '\0'; if (OP(next) == EXACTLY) nextch = *OPERAND(next); minx = (OP(scan) == STAR) ? 0 : 1; save = reginput; no = regrepeat(OPERAND(scan)); while (no >= minx) { /* If it could work, try it. */ if (nextch == '\0' || *reginput == nextch) if (regmatch(next)) return(1); /* Couldn't or didn't -- back up. */ no--; reginput = save + no; } return(0); } break; case END: return(1); /* Success! */ break; default: _error("memory corruption"); return(0); break; } scan = next; } /* * We get here only if there's trouble -- normally "case END" is * the terminating point. */ _error("corrupted pointers"); return(0); }