static const char * get_token_in(struct line_stat *ls) { int cc, esc; int in_quote = 0; if (ls->stat == PS_EOF) { return NULL; } if (ls->stat == PS_RET) { return NL; } /* トークンが始まるまで空白を読み飛ばす */ do { esc = mygetc(&cc); } while (cc > 0 && myisblank(cc) && esc == 0); if (cc == -1) { return NULL; } if (cc == '\n'){ return NL; } /**/ if (cc == '\"' && !esc) { in_quote = 1; } /**/ do { pushchar(ls, cc); esc = mygetc(&cc); if (cc < 0){ /* EOF */ pushchar(ls, 0); ls->stat = PS_EOF; return ls->buf; } if (cc == '\n' && !esc) { /* 改行 */ pushchar(ls, 0); ls->stat = PS_RET; return ls->buf; } if (!in_quote && myisblank(cc)) { break; } if (in_quote && cc == '\"' && !esc) { pushchar(ls, '\"'); break; } } while (1); pushchar(ls, 0); return ls->buf; }
static boolean mefindusedblocksvisit (hdlheadrecord hnode, ptrvoid refcon) { /* if there's a script attached to hnode, note the database usage. */ ptrstring bsparent = (ptrstring) refcon; tymenuiteminfo item; bigstring bspath; if (megetmenuiteminfo (hnode, &item)) { /*something linked*/ opgetheadstring (hnode, bspath); pushchar (']', bspath); insertstring (BIGSTRING ("\x02" " ["), bspath); insertstring (bsparent, bspath); return (statsblockinuse (item.linkedscript.adrlink, bspath)); } return (true); /*keep visiting*/ } /*mefindusedblocksvisit*/
static boolean opnavigationkey (byte chkey) { /* add chkey to the typing buffer bsselect, resetting the buffer depending on elapsed time. select the table entry that whose name starts with a string equal to or greater than the resulting string. the net effect should be much like typing in standard file. note that statics are used to retain information between calls. */ static bigstring bsselection; static long timelastkey = 0L; register byte c = chkey; register long timethiskey; hdlheadrecord hnode; timethiskey = appletevent.when; if ((timethiskey - timelastkey) > (2 * KeyThresh)) /*long enough gap, reset*/ setemptystring (bsselection); timelastkey = timethiskey; /*set up for next time*/ pushchar (chkey, bsselection); opfindhead ((**outlinedata).hbarcursor, bsselection, &hnode); opmoveto (hnode); return (true); } /*opnavigationkey*/
static boolean tablepacktotextvisit (bigstring bsname, hdlhashnode hnode, tyvaluerecord val, ptrvoid refcon) { #pragma unused (hnode) /* 4.0.2b1 dmb: handle fldiskvals. see comment in hashsortedinversesearch */ Handle htextscrap = (Handle) refcon; boolean fl; pushchar (chtab, bsname); if (!pushtexthandle (bsname, htextscrap)) return (true); /*abort traversal*/ if (val.fldiskval) if (!copyvaluerecord (val, &val)) return (true); fl = langvaluetotextscrap (val, htextscrap); if (exemptfromtmpstack (&val)) disposevaluerecord (val, false); if (!fl) return (true); return (false); /*keep going*/ } /*tablepacktotextvisit*/
static void ccupdatestatistics (boolean flbitmap) { /* 1/20/93 dmb: if fldisableyield is set, we got here in strange circumstances. most likely, it indicates that a script running as a component or fast script put up a dialog. to avoid a system crash, we must not call langrunstringnoerror. */ bigstring bs; short threadcount; // timedatestring (timenow (), bs); // ccdrawstatistic (datetimeitem, bs, flbitmap); if (aboutstatsshowing ()) { #ifdef WIN95VERSION extern long handlecounter; numbertostring (handlecounter, bs); #endif #ifdef MACVERSION long freemem = FreeMem () / 1024; numbertostring (freemem, bs); pushchar ('K', bs); #endif ccdrawstatistic (memoryitem, bs, flbitmap); threadcount = processthreadcount (); numbertostring (threadcount, bs); ccdrawstatistic (threadsitem, bs, flbitmap); ccdrawstatistic (thisthreaditem, bstheadinfo, flbitmap); ccdrawmainwindowtext (miscinfoitem, normal, bsmiscinfo, leftjustified); } /* if ((roottable != nil) && (!fldisableyield)) { if (langrunstringnoerror ("\puser.name", bs)) { ccdrawstatistic (usernameitem, bs, flbitmap); } } */ } /*ccupdatestatistics*/
boolean registerFileType (bigstring extension, bigstring filetype, bigstring contenttype, bigstring filedescription, bigstring iconfile, short iconid, bigstring shellopen) { bigstring sval, skey; if ((extension == NULL) || (filetype == NULL)) return (false); if (stringlength (extension) < 2) return (false); if (stringlength (filetype) == 0) return (false); /* Register with the Registry */ setRegKeyValue (extension, NULL, filetype); if (contenttype != NULL) { setRegKeyValue (extension, BIGSTRING ("\x0c" "Content Type"), contenttype); } if (filedescription == NULL) return (true); /* nothing more to do */ setRegKeyValue (filetype, NULL, filedescription); if (iconfile != NULL) { copystring (iconfile, sval); pushchar (',', sval); pushint (iconid, sval); copystring (filetype, skey); pushstring (BIGSTRING ("\x0c" "\\DefaultIcon"), skey); setRegKeyValue (skey, NULL, sval); } if (shellopen != NULL) { copystring (filetype, skey); pushstring (BIGSTRING ("\x13" "\\shell\\open\\command"), skey); setRegKeyValue (skey, NULL, shellopen); } return (true); }
static int eol(lua_State *L) { int context = luaL_checkint(L, 1); size_t isize = 0; const char *input = luaL_optlstring(L, 2, NULL, &isize); const char *last = input + isize; const char *marker = luaL_optstring(L, 3, CRLF); luaL_Buffer buffer; luaL_buffinit(L, &buffer); if (!input) { lua_pushnil(L); lua_pushnumber(L, 0); return 2; } while (input < last) context = pushchar(*input++, context, marker, &buffer); luaL_pushresult(&buffer); lua_pushnumber(L, context); return 2; }
boolean getuntitledfilename (bigstring bs) { /* 5.0d6 dmb: added numeric sequencing */ static long untitledsequencer = 0; if (!getstringlist (defaultlistnumber, untitledfilename, bs)) return (false); if (++untitledsequencer > 1) { pushchar ('-', bs); pushlong (untitledsequencer, bs); } return (true); } /*getuntitledfilename*/
boolean aboutsetthreadstring (hdlprocessthread hp, boolean flin) { register hdlcancoonrecord hc = cancoonglobals; hdlthreadglobals hg = (hdlthreadglobals) hp; boolean fl = false; hdlwindowinfo hinfo; if (hc == nil) return (false); if (!aboutstatsshowing ()) return (false); if (!findaboutwindow (&hinfo) || !shellpushglobals ((**hinfo).macwindow)) return (false); if (flin) { numbertostring ((long) (**hg).idthread, bstheadinfo); if ((**hg).hprocess) { pushstring (BIGSTRING ("\x02" " ["), bstheadinfo); pushstring ((**(**hg).hprocess).bsname, bstheadinfo); pushchar (']', bstheadinfo); } } else insertstring (BIGSTRING ("\x06" "(out) "), bstheadinfo); if (aboutdata != nil) ccupdatestatistics (false); shellpopglobals (); return (fl); } /*aboutsetthreadstring*/
boolean getuntitledfilename (bigstring bs) { // // 2006-09-15 creedon; push space character instead of dash // // 5.0d6 dmb: added numeric sequencing // static long untitledsequencer = 0; if (!getstringlist (defaultlistnumber, untitledfilename, bs)) return (false); if (++untitledsequencer > 1) { pushchar ( ' ', bs ); pushlong (untitledsequencer, bs); } return (true); } // getuntitledfilename
/* hash some C/C++ code after unifying */ static void unify(unsigned char *p, size_t size) { size_t ofs; unsigned char q; int i; build_table(); for (ofs=0; ofs<size;) { if (p[ofs] == '#') { if ((size-ofs) > 2 && p[ofs+1] == ' ' && isdigit(p[ofs+2])) { do { ofs++; } while (ofs < size && p[ofs] != '\n'); ofs++; } else { do { pushchar(p[ofs]); ofs++; } while (ofs < size && p[ofs] != '\n'); pushchar('\n'); ofs++; } continue; } if (tokens[p[ofs]].type & C_ALPHA) { do { pushchar(p[ofs]); ofs++; } while (ofs < size && (tokens[p[ofs]].type & (C_ALPHA|C_DIGIT))); pushchar('\n'); continue; } if (tokens[p[ofs]].type & C_DIGIT) { do { pushchar(p[ofs]); ofs++; } while (ofs < size && ((tokens[p[ofs]].type & C_DIGIT) || p[ofs] == '.')); if (ofs < size && (p[ofs] == 'x' || p[ofs] == 'X')) { do { pushchar(p[ofs]); ofs++; } while (ofs < size && (tokens[p[ofs]].type & C_HEX)); } if (ofs < size && (p[ofs] == 'E' || p[ofs] == 'e')) { pushchar(p[ofs]); ofs++; while (ofs < size && (tokens[p[ofs]].type & (C_DIGIT|C_SIGN))) { pushchar(p[ofs]); ofs++; } } while (ofs < size && (tokens[p[ofs]].type & C_FLOAT)) { pushchar(p[ofs]); ofs++; } pushchar('\n'); continue; } if (tokens[p[ofs]].type & C_SPACE) { do { ofs++; } while (ofs < size && (tokens[p[ofs]].type & C_SPACE)); continue; } if (tokens[p[ofs]].type & C_QUOTE) { q = p[ofs]; pushchar(p[ofs]); do { ofs++; while (ofs < size-1 && p[ofs] == '\\') { pushchar(p[ofs]); pushchar(p[ofs+1]); ofs+=2; } pushchar(p[ofs]); } while (ofs < size && p[ofs] != q); pushchar('\n'); ofs++; continue; } if (tokens[p[ofs]].type & C_TOKEN) { q = p[ofs]; for (i=0;i<tokens[q].num_toks;i++) { unsigned char *s = (unsigned char *)tokens[q].toks[i]; int len = strlen((char *)s); if (size >= ofs+len && memcmp(&p[ofs], s, len) == 0) { int j; for (j=0;s[j];j++) { pushchar(s[j]); ofs++; } pushchar('\n'); break; } } if (i < tokens[q].num_toks) { continue; } } pushchar(p[ofs]); pushchar('\n'); ofs++; } pushchar(0); }
void xcmdcallback (void) { /* 5/4/92 dmb: HyperCard 1.0 XCMD callback emulation 7/8/92 dmb: set return code; use xresNotImp for unknown request 9/25/92 dmb: added SendHCEvent callback support. also spotted & fixed a bug in ExtToStr handler. 10/3/92 dmb: it turns out that the protocol requires that the caller of the xcmd put the xcmdptr into a global for us; the xcmd code doesn't pass it to us consistently. 11/6/92 dmb: use new truncatecstringhandle instead of just popping last char. also, fixed NumToHex, NumToStr */ register XCmdPtr pxcb; register long *args; register long *out; tyvaluerecord val; bigstring bs; hdlhashtable htable; hdlhashnode hnode; pxcb = plangxcmdrec; /*copy global into register*/ args = (*pxcb).inArgs; out = (long *) &(*pxcb).outArgs; (*pxcb).result = xresSucc; switch ((*pxcb).request) { /* HyperTalk Utilities */ case 0x02: /*Handle EvalExpr (StringPtr expr)*/ if (!langrunstringnoerror ((ptrstring) args [0], bs)) (*pxcb).result = xresFail; else { pushchar (chnul, bs); newtexthandle (bs, (Handle *) out); } break; case 0x01: /*void SendCardMessage (StringPtr msg)*/ case 0x05: /*void SendHCMessage (StringPtr msg)*/ if (!langrunstringnoerror ((ptrstring) args [0], bs)) (*pxcb).result = xresFail; break; /* case 0x26: /*void RunHandler (Handle handler)%/ break; */ /* Memory Utilities */ case 0x12: /*Handle GetGlobal (StringPtr globName)*/ resolvexcmdglobal ((ptrstring) args [0], &htable, bs); if (hashtablelookup (htable, bs, &val, &hnode) && copyvaluerecord (val, &val) && coercetostring (&val) && enlargehandle (val.data.stringvalue, 1, zerostring)) { exemptfromtmpstack (&val); *out = (long) val.data.stringvalue; } else *out = 0L; break; case 0x13: /*void SetGlobal (StringPtr globName, Handle globValue)*/ resolvexcmdglobal ((ptrstring) args [0], &htable, bs); initvalue (&val, stringvaluetype); if (!copyhandle ((Handle) args [1], &val.data.stringvalue)) (*pxcb).result = xresFail; else { truncatecstringhandle (val.data.stringvalue); /*strip zero terminator*/ if (!hashtableassign (htable, bs, val)) disposevaluerecord (val, false); } break; case 0x06: /*void ZeroBytes (Ptr dstPtr, long longCount)*/ clearbytes ((byte *) args [0], args [1]); break; /* String Utilities */ case 0x1c: /*void ScanToReturn (Ptr *scanPtr)*/ scantext (chreturn, (ptrbyte *) args [0]); /*** test: ++*(ptrbyte *) args [0]; /*point past return*/ break; case 0x27: /*void ScanToZero (Ptr *scanPtr)*/ scantext (chnul, (ptrbyte *) args [0]); break; case 0x1a: /*Boolean StringEqual (StringPtr str1, StringPtr str2)*/ *out = (long) equalstrings ((ptrstring) args [0], (ptrstring) args [1]); break; case 0x03: { /*long StringLength (Ptr strPtr)*/ *out = scanlength (chnul, (ptrbyte) args [0]); break; } case 0x04: { /*Ptr StringMatch (StringPtr pattern, Ptr target)*/ tysearchparameters saveparams = searchparams; long ix = 0; long len; searchparams.flunicase = false; searchparams.flwholewords = false; searchparams.flregexp = false; copystring ((ptrstring) args [0], searchparams.bsfind); textsearch ((ptrbyte) args [1], infinity, &ix, &len); *out = (long) ((ptrbyte) args [1] + ix); searchparams = saveparams; break; } case 0x20: /*void ZeroTermHandle (Handle hndl)*/ enlargehandle ((Handle) args [0], 1, zerostring); break; /* String Conversions */ case 0x10: /*void BoolToStr (Boolean bool, StringPtr str)*/ setbooleanvalue ((Boolean) args [0], &val); valtostring (&val, (ptrstring) args [1]); break; case 0x11: { /*void ExtToStr (extended num, StringPtr str)*/ #if __powerc long double x; safex80told ((extended80 *) args [0], &x); setdoublevalue (x, &val); #else setdoublevalue (* (long double *) args [0], &val); #endif valtostring (&val, (ptrstring) args [1]); break; } case 0x0d: /*void LongToStr (long posNum, StringPtr str)*/ setlongvalue ((unsigned long) args [0], &val); /*11/6/92 dmb*/ valtostring (&val, (ptrstring) args [1]); break; case 0x0f: { /*void NumToHex (long num, short nDigits, StringPtr str)*/ long n = args [0]; byte hex [16]; if (args [1] <= 4) n = (short) n; numbertohexstring (n, hex); /*11/6/92 dmb*/ deletestring (hex, 1, 2); /*remove the "0x"*/ copystring (hex, (ptrstring) args [2]); break; } case 0x0e: /*void NumToStr (long num, StringPtr str)*/ setlongvalue ((long) args [0], &val); /*11/6/92 dmb*/ valtostring (&val, (ptrstring) args [1]); break; case 0x07: /*Handle PasToZero (StringPtr str)*/ copystring ((ptrstring) args [0], bs); pushchar (chnul, bs); newtexthandle (bs, (Handle *) out); break; case 0x2b: /*void PointToStr (Point pt, StringPtr str)*/ setpointvalue (*(Point *) args [0], &val); valtostring (&val, (ptrstring) args [1]); break; case 0x2c: /*void RectToStr (Rect *rct, StringPtr str)*/ newheapvalue ((Rect *) args [0], longsizeof (Rect), rectvaluetype, &val); valtostring (&val, (ptrstring) args [1]); break; case 0x1b: /*void ReturnToPas (Ptr zeroStr, StringPtr pasStr)*/ texttostring ((ptrbyte) args [0], scanlength (chreturn, (ptrbyte) args [0]), (ptrstring) args [1]); break; case 0x0b: /*Boolean StrToBool (StringPtr str)*/ stringtoval ((ptrstring) args [0], booleanvaluetype, &val); *out = (long) val.data.flvalue; break; case 0x0c: { /*extended StrToExt (StringPtr str)*/ #if __powerc long double x; stringtoval ((ptrstring) args [0], doublevaluetype, &val); x = **val.data.doublevalue; safeldtox80 (&x, (extended80 *) args [1]); #else stringtoval ((ptrstring) args [0], doublevaluetype, &val); *(double *) args [1] = **val.data.doublevalue; #endif break; } case 0x09: /*long StrToLong (StringPtr str)*/ stringtoval ((ptrstring) args [0], longvaluetype, &val); *out = abs (val.data.longvalue); break; case 0x0a: /*long StrToNum (StringPtr str)*/ stringtoval ((ptrstring) args [0], longvaluetype, &val); *out = (long) val.data.longvalue; break; case 0x2d: /*void StrToPoint (StringPtr str, Point *pt)*/ stringtoval ((ptrstring) args [0], pointvaluetype, &val); *(Point *) args [1] = val.data.pointvalue; break; case 0x2e: /*void StrToRect (StringPtr str, Rect *rct)*/ stringtoval ((ptrstring) args [0], rectvaluetype, &val); *(Rect *) args [1] = **val.data.rectvalue; break; case 0x08: /*void ZeroToPas (Ptr zeroStr, StringPtr pasStr)*/ texttostring ((ptrbyte) args [0], scanlength (chnul, (ptrbyte) args [0]), (ptrstring) args [1]); break; #if 0 /* Field Utilities */ case 0x16: /*Handle GetFieldByID (Boolean cardFieldFlag, short fieldID)*/ newfilledhandle (zerostring, 1L, (Handle *) out); break; case 0x14: /*Handle GetFieldByName (Boolean cardFieldFlag, StringPtr fieldName)*/ newfilledhandle (zerostring, 1L, (Handle *) out); break; case 0x15: /*Handle GetFieldByNum (Boolean cardFieldFlag, short fieldNum)*/ newfilledhandle (zerostring, 1L, (Handle *) out); break; case 0x19: /*void SetFieldByID (Boolean cardFieldFlag, short fieldID, Handle fieldVal)*/ break; case 0x17: /*void SetFieldByName (Boolean cardFieldFlag, StringPtr fieldName, Handle fieldVal)*/ break; case 0x18: /*void SetFieldByNum (Boolean cardFieldFlag, short fieldNum, Handle fieldVal)*/ break; case 0x2f: /*TEHandle GetFieldTE (Boolean cardFieldFlag, short fieldID, short fieldNum, StringPtr fieldNamePtr)*/ *out = 0; break; case 0x30: /*void SetFieldTE (Boolean cardFieldFlag, short fieldID, short fieldNum, StringPtr fieldNamePtr, TEHandle fieldTE)*/ break; #endif case 0x22: /*void SendHCEvent(EventRecord *event)*/ /****component***/ shellpostevent ((EventRecord *) &args [0]); /*yes, the event itself is in args*/ shellforcebackgroundtask (); /*come back as soon as possible*/ if (!processyield ()) /*we've been killed*/ (*pxcb).result = xresFail; break; default: *out = 0L; (*pxcb).result = xresNotImp; break; } plangxcmdrec = pxcb; /*reset in case another xcmd ran in the background*/ } /*xcmdcallback*/
int page_switch() { register char *s; switch (*buf) { case 'd': case Ctl('d'): /* half page */ special = TRUE; slines = LINES / 2 + 1; if (marking && *blinebeg != '\f' #ifdef CUSTOMLINES && (!pagestop || blinebeg != art_buf || !execute(&page_compex,blinebeg)) #endif ) { up_line(); highlight = --artline; restart = blinebeg; artpos = alinebeg; } return PS_NORM; case '!': /* shell escape */ escapade(); return PS_ASK; #ifdef INNERSEARCH case Ctl('i'): gline = 3; sprintf(cmd_buf,"^[^%c]",*blinebeg); compile(&gcompex,cmd_buf,TRUE,TRUE); goto caseG; case Ctl('g'): gline = 3; compile(&gcompex,"^Subject:",TRUE,TRUE); goto caseG; case 'g': /* in-article search */ if (!finish_command(FALSE))/* get rest of command */ return PS_ASK; s = buf+1; if (isspace(*s)) s++; if ((s = compile(&gcompex,s,TRUE,TRUE)) != Nullch) { /* compile regular expression */ printf("\n%s\n",s) FLUSH; return PS_ASK; } carriage_return(); erase_eol(); /* erase the prompt */ /* FALL THROUGH */ caseG: case 'G': { /* ART_LINE lines_to_skip = 0; */ ART_POS start_where; if (gline < 0 || gline > LINES-2) gline = LINES-2; #ifdef DEBUGGING if (debug & DEB_INNERSRCH) printf("Start here? %d >=? %d\n",topline + gline + 1,artline) FLUSH; #endif if (*buf == Ctl('i') || topline+gline+1 >= artline) start_where = artpos; /* in case we had a line wrap */ else { start_where = vrdary(topline+gline+1); if (start_where < 0) start_where = -start_where; } if (start_where < htype[PAST_HEADER].ht_minpos) start_where = htype[PAST_HEADER].ht_minpos; fseek(artfp,(long)start_where,0); innersearch = 0; /* assume not found */ while (fgets(buf, sizeof buf, artfp) != Nullch) { /* lines_to_skip++; NOT USED NOW */ #ifdef DEBUGGING if (debug & DEB_INNERSRCH) printf("Test %s",buf) FLUSH; #endif if (execute(&gcompex,buf) != Nullch) { innersearch = ftell(artfp); break; } } if (!innersearch) { fseek(artfp,artpos,0); fputs("(Not found)",stdout) FLUSH; return PS_ASK; } #ifdef DEBUGGING if (debug & DEB_INNERSRCH) printf("On page? %ld <=? %ld\n",(long)innersearch,(long)artpos) FLUSH; #endif if (innersearch <= artpos) { /* already on page? */ if (innersearch < artpos) { artline = topline+1; while (vrdary(artline) < innersearch) artline++; } highlight = artline - 1; #ifdef DEBUGGING if (debug & DEB_INNERSRCH) printf("@ %d\n",highlight) FLUSH; #endif topline = highlight - gline; if (topline < -1) topline = -1; *buf = '\f'; /* fake up a refresh */ innersearch = 0; return page_switch(); } else { /* who knows how many lines it is? */ do_fseek = TRUE; hide_everything = TRUE; } return PS_NORM; } #else case 'g': case 'G': case Ctl('g'): notincl("g"); return PS_ASK; #endif case '\n': /* one line */ special = TRUE; slines = 2; return PS_NORM; #ifdef ROTATION case 'X': rotate = !rotate; /* FALL THROUGH */ #endif case 'l': case '\f': /* refresh screen */ #ifdef DEBUGGING if (debug & DEB_INNERSRCH) { printf("Topline = %d",topline) FLUSH; gets(buf); } #endif clear(); do_fseek = TRUE; artline = topline; if (artline < 0) artline = 0; firstpage = (topline < 0); return PS_NORM; case 'b': case '\b': /* I like backspace for this -- PWP */ /* Leaving it undocumented in case */ /* I want to steal the key--LAW */ case Ctl('b'): { /* back up a page */ ART_LINE target; #ifndef CLEAREOL clear(); #else if (can_home_clear) /* if we can home do it -- PWP */ home_cursor(); else clear(); #endif CLEAREOL do_fseek = TRUE; /* reposition article file */ target = topline - (LINES - 2); artline = topline; do { artline--; } while (artline >= 0 && artline > target && vrdary(artline-1) >= 0); topline = artline; /* remember top line of screen */ /* (line # within article file) */ if (artline < 0) artline = 0; firstpage = (topline < 0); return PS_NORM; } case 'h': { /* help */ int cmd; if ((cmd = help_page()) > 0) pushchar(cmd); return PS_ASK; } case '\177': case '\0': /* treat del,break as 'n' */ *buf = 'n'; /* FALL THROUGH */ case 'k': case 'K': case 'n': case 'N': case Ctl('n'): case 's': case 'S': case 'u': case 'w': case 'W': case '|': mark_as_read(art); /* mark article as read */ /* FALL THROUGH */ case '#': case '$': case '&': case '-': case '.': case '/': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case '=': case '?': case 'c': case 'C': case 'f': case 'F': case 'j': case Ctl('k'): case 'm': case 'M': case 'p': case 'P': case Ctl('p'): case 'Q': case 'r': case 'R': case Ctl('r'): case 'v': case 'Y': #ifndef ROTATION case 'x': case 'X': #endif case Ctl('x'): case '^': #ifdef ROTATION rotate = FALSE; #endif reread = FALSE; do_hiding = TRUE; if (index("nNpP",*buf) == Nullch && index("wWsS!&|/?123456789.",*buf) != Nullch) { setdfltcmd(); standout(); /* enter standout mode */ printf(prompt,mailcall,dfltcmd); /* print prompt, whatever it is */ un_standout(); /* leave standout mode */ putchar(' '); fflush(stdout); } return PS_RAISE; /* and pretend we were at end */ #ifdef ROTATION case 'x': rotate = TRUE; /* FALL THROUGH */ #endif case 'y': case Ctl('v'): /* I like emacs -- PWP */ /* Leaving it undocumented in case */ /* I want to steal the key--LAW */ case ' ': /* continue current article */ if (erase_screen) { /* -e? */ #ifndef CLEAREOL clear(); /* clear screen */ #else if (can_home_clear) /* if we can home do it -- PWP */ home_cursor(); else clear(); /* else clear screen */ #endif CLEAREOL if (*blinebeg != '\f' #ifdef CUSTOMLINES && (!pagestop || blinebeg != art_buf || !execute(&page_compex,blinebeg)) #endif ) { restart = blinebeg; artline--; /* restart this line */ artpos = alinebeg; if (marking) /* and mark repeated line */ highlight = artline; } topline = artline; /* and remember top line of screen */ /* (line # within article file) */ } else if (marking && *blinebeg != '\f' #ifdef CUSTOMLINES && (!pagestop || blinebeg != art_buf || !execute(&page_compex,blinebeg)) #endif ) { /* are we marking repeats? */ up_line(); /* go up one line */ highlight = --artline;/* and get ready to highlight */ restart = blinebeg; /* the old line */ artpos = alinebeg; } return PS_NORM; case 'q': /* quit this article? */ do_hiding = TRUE; return PS_TOEND; default: fputs(hforhelp,stdout) FLUSH; settle_down(); return PS_ASK; } }
short __assert (char *expr, char *file, short line) { /* On OS X, DebugStr output gets automatically rerouted to stderr which in turn gets logged to console.log, viewable via Console.app. 2003-05-26 AR: Include date/time, app name, and app version. */ static boolean flnorentry = false; short day, month, year, hour, minute, second; tyfilespec myfspec; bigstring bs, bslogstamp, bsline, bsfile, bsmessage; if (flnorentry) return (0); flnorentry = true; /*get timestamp*/ secondstodatetime (timenow (), &day, &month, &year, &hour, &minute, &second); numbertostring ((long) year, bs); pushstring (bs, bslogstamp); pushchar ('-', bslogstamp); numbertostring ((long) month, bs); padwithzeros (bs, 2); pushstring (bs, bslogstamp); pushchar ('-', bslogstamp); numbertostring ((long) day, bs); padwithzeros (bs, 2); pushstring (bs, bslogstamp); pushchar (' ', bslogstamp); numbertostring ((long) hour, bs); padwithzeros (bs, 2); pushstring (bs, bslogstamp); pushchar (':', bslogstamp); numbertostring ((long) minute, bs); padwithzeros (bs, 2); pushstring (bs, bslogstamp); pushchar (':', bslogstamp); numbertostring ((long) second, bs); padwithzeros (bs, 2); pushstring (bs, bslogstamp); pushchar (' ', bslogstamp); /*get filespec for app*/ getapplicationfilespec (nil, &myfspec); pushstring (fsname (&myfspec), bslogstamp); pushchar (' ', bslogstamp); /*get version of app*/ filegetprogramversion (bs); pushchar ('(', bslogstamp); pushstring (bs, bslogstamp); pushchar (')', bslogstamp); /*get file name*/ moveleft (file, bsfile, (long) lenbigstring); convertcstring (bsfile); /*get line number*/ numbertostring ((long) line, bsline); /*ouput message*/ parsedialogstring ( "\p\r^0: Assertion failed in file ^1, at line ^2.\r", bslogstamp, bsfile, bsline, nil, bsmessage); DebugStr (bsmessage); /*send message to stderr*/ flnorentry = false; return (0); } /*__assert*/
static boolean browsercollisiondialog (hdlheadrecord hdest, ptrdraginfo draginfo) { #pragma unused (hdest) /* 2005-09-26 creedon: changed default order of buttons, default is Duplicate which is the safe option, checks user.prefs.flReplaceDialogExpertMode and if true Replace is the default option */ bigstring bs, bscollided, prompt; bigstring nobutton, yesbutton; short itemhit; boolean fl, flExpertMode = false; if ((*draginfo).collisiontype == nocollisions) /*no confirmation or deletions needed*/ return (true); if ((*draginfo).ctcollisions > 1) { copystring (dialogstrings [ixsomeitems], prompt); pushstring (actionstrings [(*draginfo).action], prompt); pushchar ('.', prompt); } else { copystring (dialogstrings [ixan], prompt); switch ((*draginfo).collisiontype) { case collidewithnewer: copystring (dialogstrings [ixanewer], prompt); break; case collidewitholder: copystring (dialogstrings [ixanolder], prompt); break; } /*switch*/ pushstring (dialogstrings [ixitemnamed], prompt); opgetheadstring ((*draginfo).hcollided, bscollided); pushstring (bscollided, prompt); pushstring (dialogstrings [ixalreadyexists], prompt); } getsystemtablescript (idreplacedialogexpertmode, bs); // "user.prefs.flReplaceDialogExpertMode" disablelangerror (); fl = langrunstring (bs, bs); enablelangerror (); if (fl) stringisboolean (bs, &flExpertMode); if (flExpertMode) { copystring (duplicatebuttontext, nobutton); copystring (replacebuttontext, yesbutton); } else { copystring (duplicatebuttontext, yesbutton); copystring (replacebuttontext, nobutton); } itemhit = threewaydialog (prompt, yesbutton, nobutton, cancelbuttontext); if (flExpertMode) switch (itemhit) { case 1: itemhit = 2; break; case 2: itemhit = 1; break; } switch (itemhit) { case 1: opcleartmpbits (); /*caller should rename items where conflicts occur*/ return (true); case 2: /*caller should delete all files with their tmpbit set*/ return (true); default: opcleartmpbits (); return (false); } /* switch */ } /*browsercollisiondialog*/