/* * processSetToken - set value for set token */ static vi_rc processSetToken( int j, char *value, int *winflag, bool isnonbool ) { char fn[MAX_STR], str[MAX_STR]; #ifndef VICOMP char tmp[3]; char settokstr[TOK_MAX_LEN + 1]; char save[MAX_STR]; vi_rc rc = ERR_NO_ERR; int i, clr, k; bool newset; bool set1, toggle, *ptr; jmp_buf jmpaddr; cursor_type ct; char *name; command_rtn fptr; event_bits eb; bool redisplay = FALSE; #endif bool bvalue; #ifdef VICOMP winflag = winflag; isnonbool = isnonbool; #endif /* * set up value for boolean set commands */ if( j < 0 ) { j *= -1; bvalue = FALSE; } else { bvalue = TRUE; } #ifndef VICOMP if( !(*winflag) ) { toggle = TRUE; set1 = isnonbool; } else { toggle = FALSE; #endif if( j >= SET1_T_ ) { #ifndef VICOMP if( EditFlags.CompileScript ) { #endif if( !bvalue ) { j *= -1; } itoa( j, str, 10 ); StrMerge( 2, WorkLine->data, str, SingleBlank ); return( ERR_NO_ERR ); #ifndef VICOMP } set1 = FALSE; j -= SET1_T_; } else { set1 = TRUE; #endif } #ifndef VICOMP } *winflag = FALSE; /* * process boolean settings */ if( !set1 ) { if( j >= SET2_T_ ) { return( ERR_INVALID_SET_COMMAND ); } ptr = &(((bool *)&EditFlags)[j]); newset = bvalue; if( toggle ) { newset = !(*ptr); } switch( j ) { case SET2_T_MODELESS: if( (newset && !EditFlags.Modeless) || (!newset && EditFlags.Modeless) ) { for( k = 0; k < MAX_EVENTS; k++ ) { fptr = EventList[k].rtn; eb = EventList[k].b; EventList[k].rtn = EventList[k].alt_rtn; EventList[k].alt_rtn = fptr; EventList[k].b = EventList[k].alt_b; EventList[k].alt_b = eb; } if( !EditFlags.Modeless ) { if( MenuWindow != NO_WINDOW ) { UpdateCurrentStatus( CSTATUS_INSERT ); } EditFlags.WasOverstrike = FALSE; NewCursor( CurrentWindow, EditVars.InsertCursorType ); } else { if( MenuWindow != NO_WINDOW ) { UpdateCurrentStatus( CSTATUS_COMMAND ); } NewCursor( CurrentWindow, EditVars.NormalCursorType ); // nomodeless must be line based or it dies! EditFlags.LineBased = TRUE; } /* re-position cursor in window */ SetWindowCursor(); } EditFlags.Modeless = newset; break; case SET2_T_UNDO: if( EditFlags.Undo && !newset ) { FreeAllUndos(); } EditFlags.Undo = newset; break; case SET2_T_STATUSINFO: EditFlags.StatusInfo = newset; #ifdef __WIN__ ResizeRoot(); #endif rc = NewStatusWindow(); break; case SET2_T_WINDOWGADGETS: EditFlags.WindowGadgets = newset; ResetAllWindows(); *winflag = TRUE; redisplay = TRUE; break; case SET2_T_REALTABS: EditFlags.RealTabs = newset; redisplay = TRUE; break; case SET2_T_CLOCK: EditFlags.Clock = newset; redisplay = TRUE; break; case SET2_T_TOOLBAR: EditFlags.Toolbar = newset; #ifdef __WIN__ ResizeRoot(); #endif break; case SET2_T_COLORBAR: EditFlags.Colorbar = newset; #ifdef __WIN__ if( Root == NULL ) { EditFlags.Colorbar = FALSE; } else { RefreshColorbar(); } #endif break; case SET2_T_SSBAR: EditFlags.SSbar = newset; #ifdef __WIN__ if( Root == NULL ) { EditFlags.SSbar = FALSE; } else { RefreshSSbar(); } #endif break; case SET2_T_FONTBAR: EditFlags.Fontbar = newset; #ifdef __WIN__ if( Root == NULL ) { EditFlags.Fontbar = FALSE; } else { RefreshFontbar(); } #endif break; case SET2_T_MARKLONGLINES: EditFlags.MarkLongLines = newset; break; case SET2_T_MENUS: EditFlags.Menus = newset; InitMenu(); break; case SET2_T_LINENUMBERS: if( toggle ) { newset = !EditFlags.LineNumbers; } if( newset != EditFlags.LineNumbers ) { EditFlags.LineNumbers = newset; rc = LineNumbersSetup(); *winflag = TRUE; } break; case SET2_T_CURRENTSTATUS: EditFlags.CurrentStatus = newset; InitMenu(); break; case SET2_T_DISPLAYSECONDS: EditFlags.DisplaySeconds = newset; redisplay = TRUE; break; case SET2_T_PPKEYWORDONLY: EditFlags.PPKeywordOnly = newset; redisplay = TRUE; break; case SET2_T_LASTEOL: #ifndef __WIN__ *ptr = TRUE; toggle = FALSE; break; #endif default: *ptr = newset; break; } if( msgFlag ) { if( !newset ) { tmp[0] = 'n'; tmp[1] = 'o'; tmp[2] = 0; } else { tmp[0] = 0; } MySprintf( fn, "%s%s set", tmp, GetTokenStringCVT( SetTokens2, j, settokstr, TRUE ) ); } if( toggle ) { strcpy( save, BoolStr[(int) newset] ); (*winflag) += 1; } /* * process value settings */ } else { if( toggle ) { rc = GetNewValueDialog( value ); if( rc != ERR_NO_ERR ) { return( rc ); } strcpy( save, value ); } #endif /* VICOMP */ RemoveLeadingSpaces( value ); if( value[0] == '"' ) { NextWord( value, fn, "\"" ); EliminateFirstN( value, 1 ); } else { NextWord1( value, fn ); } #ifndef VICOMP if( EditFlags.CompileScript ) { #endif itoa( j, str, 10 ); strcat( WorkLine->data, str ); if( fn[0] == '\0' ) return( ERR_NO_ERR ); switch( j ) { case SET1_T_STATUSSTRING: case SET1_T_FILEENDSTRING: case SET1_T_HISTORYFILE: case SET1_T_TMPDIR: case SET1_T_TAGFILENAME: StrMerge( 4, WorkLine->data, SingleBlank, SingleQuote, fn, SingleQuote ); break; case SET1_T_COMMANDCURSORTYPE: case SET1_T_OVERSTRIKECURSORTYPE: case SET1_T_INSERTCURSORTYPE: StrMerge( 2, WorkLine->data, SingleBlank, fn ); if( NextWord1( value, fn ) <= 0 ) { break; } StrMerge( 2, WorkLine->data, SingleBlank, fn ); break; case SET1_T_TILECOLOR: StrMerge( 2, WorkLine->data, SingleBlank, fn ); if( NextWord1( value, fn ) <= 0 ) { return( ERR_INVALID_SET_COMMAND ); } if( NextWord1( value, str ) <= 0 ) { return( ERR_INVALID_SET_COMMAND ); } StrMerge( 4, WorkLine->data, fn, SingleBlank, str, SingleBlank ); break; case SET1_T_STATUSSECTIONS: StrMerge( 2, WorkLine->data, SingleBlank, fn ); while( NextWord1( value, fn ) > 0 ) { #ifdef VICOMP int k; #endif k = atoi( fn ); if( k <= 0 ) { break; } StrMerge( 2, WorkLine->data, SingleBlank, fn ); } break; default: StrMerge( 2, WorkLine->data, SingleBlank, fn ); break; } return( ERR_NO_ERR ); #ifndef VICOMP } switch( j ) { case SET1_T_STATUSSECTIONS: if( EditVars.StatusSections != NULL ) { MemFree( EditVars.StatusSections ); EditVars.StatusSections = NULL; EditVars.NumStatusSections = 0; } for( ;; ) { k = atoi( fn ); if( k <= 0 ) { break; } EditVars.StatusSections = MemReAlloc( EditVars.StatusSections, sizeof( short ) * (EditVars.NumStatusSections + 1) ); EditVars.StatusSections[EditVars.NumStatusSections] = k; EditVars.NumStatusSections++; if( NextWord1( value, fn ) <= 0 ) { break; } } if( EditVars.StatusSections == NULL ) { MySprintf( fn, "statussections turned off" ); } else { MySprintf( fn, "statussections set" ); } break; case SET1_T_FILEENDSTRING: AddString2( &EditVars.FileEndString, fn ); ResetAllWindows(); redisplay = TRUE; break; case SET1_T_STATUSSTRING: AddString2( &EditVars.StatusString, fn ); if( StatusWindow != NO_WINDOW ) { ClearWindow( StatusWindow ); UpdateStatusWindow(); } if( msgFlag ) { MySprintf( fn, "statusstring set to %s", EditVars.StatusString ); } break; case SET1_T_GREPDEFAULT: AddString2( &EditVars.GrepDefault, fn ); break; case SET1_T_TILECOLOR: if( EditVars.TileColors == NULL ) { EditVars.TileColors = (type_style *) MemAlloc( sizeof( type_style ) * ( EditVars.MaxTileColors + 1 ) ); for( i = 0; i <= EditVars.MaxTileColors; ++i ) { EditVars.TileColors[i].foreground = -1; EditVars.TileColors[i].background = -1; EditVars.TileColors[i].font = -1; } } clr = atoi( fn ); if( clr > EditVars.MaxTileColors ) { return( ERR_INVALID_SET_COMMAND ); } if( NextWord1( value, fn ) <= 0 ) { return( ERR_INVALID_SET_COMMAND ); } EditVars.TileColors[clr].foreground = atoi( fn ); if( NextWord1( value, fn ) <= 0 ) { return( ERR_INVALID_SET_COMMAND ); } EditVars.TileColors[clr].background = atoi( fn ); EditVars.TileColors[clr].font = FONT_DEFAULT; if( msgFlag ) { MySprintf( fn, "tilecolor %d set", clr ); } break; case SET1_T_GADGETSTRING: SetGadgetString( fn ); if( msgFlag ) { MySprintf( fn, "gadget string set to %s", EditVars.GadgetString ); } ResetAllWindows(); break; case SET1_T_SHELLPROMPT: AddString2( &EditVars.SpawnPrompt, fn ); if( msgFlag ) { MySprintf( fn, "prompt string set to %s", EditVars.SpawnPrompt ); } break; case SET1_T_FIGNORE: if( fn[0] == 0 ) { MemFreePtr( (void **)&EditVars.FIgnore ); EditVars.CurrFIgnore = 0; if( msgFlag ) { MySprintf( fn, "fignore reset" ); } } else { EditVars.FIgnore = MemReAlloc( EditVars.FIgnore, EXTENSION_LENGTH * (EditVars.CurrFIgnore + 1) ); str[0] = '.'; str[1] = 0; strcat( str, fn ); str[EXTENSION_LENGTH - 1] = 0; strcpy( &EditVars.FIgnore[EXTENSION_LENGTH * EditVars.CurrFIgnore], str ); EditVars.CurrFIgnore++; if( msgFlag ) { MySprintf( fn, "%s added to fignore", str ); } } break; case SET1_T_HISTORYFILE: AddString2( &EditVars.HistoryFile, fn ); if( msgFlag ) { MySprintf( fn, "history file set to %s", EditVars.HistoryFile ); } break; case SET1_T_TAGFILENAME: AddString2( &EditVars.TagFileName, fn ); if( msgFlag ) { MySprintf( fn, "tag file name set to %s", EditVars.TagFileName ); } break; case SET1_T_FILENAME: if( CurrentFile != NULL ) { AddString2( &(CurrentFile->name), fn ); SetFileWindowTitle( CurrentWindow, CurrentInfo, TRUE ); if( msgFlag ) { MySprintf( fn, "filename set to %s", CurrentFile->name ); } FileSPVAR(); } break; case SET1_T_TMPDIR: AddString2( &EditVars.TmpDir, fn ); VerifyTmpDir(); if( msgFlag ) { MySprintf( fn, "tmpdir set to %s", EditVars.TmpDir ); } break; case SET1_T_WORD: AddString2( &EditVars.WordDefn, fn ); InitWordSearch( EditVars.WordDefn ); if( msgFlag ) { MySprintf( fn, "word set to %s", EditVars.WordDefn ); } break; case SET1_T_WORDALT: AddString2( &EditVars.WordAltDefn, fn ); if( msgFlag ) { MySprintf( fn, "wordalt set to %s", EditVars.WordAltDefn ); } break; case SET1_T_MAGICSTRING: AddString2( &EditVars.Majick, fn ); if( msgFlag ) { MySprintf( fn, "magicstring set to %s", EditVars.Majick ); } break; case SET1_T_COMMANDCURSORTYPE: case SET1_T_OVERSTRIKECURSORTYPE: case SET1_T_INSERTCURSORTYPE: i = setjmp( jmpaddr ); if( i != 0 ) { return( ERR_INVALID_SET_COMMAND ); } StartExprParse( fn, jmpaddr ); ct.height = GetConstExpr(); if( NextWord1( value, fn ) <= 0 ) { ct.width = 100; } else { i = setjmp( jmpaddr ); if( i != 0 ) { return( ERR_INVALID_SET_COMMAND ); } StartExprParse( fn, jmpaddr ); ct.width = GetConstExpr(); } if( j == SET1_T_COMMANDCURSORTYPE ) { EditVars.NormalCursorType = ct; name = "command"; } else if( j == SET1_T_OVERSTRIKECURSORTYPE ) { EditVars.OverstrikeCursorType = ct; name = "overstrike"; } else { EditVars.InsertCursorType = ct; name = "insert"; } if( msgFlag ) { MySprintf( fn, "%s cursor type set to %d,%d", name, ct.height, ct.width ); } break; default: i = setjmp( jmpaddr ); if( i != 0 ) { return( ERR_INVALID_SET_COMMAND ); } StartExprParse( fn, jmpaddr ); i = GetConstExpr(); if( i < 0 ) { i = 0; } switch( j ) { case SET1_T_WRAPMARGIN: EditVars.WrapMargin = i; break; case SET1_T_CURSORBLINKRATE: SetCursorBlinkRate( i ); break; case SET1_T_MAXPUSH: EditVars.MaxPush = i; if( EditVars.MaxPush < 1 ) { EditVars.MaxPush = 1; } InitFileStack(); break; case SET1_T_RADIX: EditVars.Radix = i; break; case SET1_T_AUTOSAVEINTERVAL: EditVars.AutoSaveInterval = i; SetNextAutoSaveTime(); break; case SET1_T_LANGUAGE: if( i < LANG_NONE || i >= LANG_MAX ) { return( ERR_INVALID_SET_COMMAND ); } if( CurrentInfo != NULL ) { LangFini( CurrentInfo->fsi.Language ); LangInit( i ); redisplay = TRUE; } break; case SET1_T_MOVECOLOR: EditVars.MoveColor = i; break; case SET1_T_RESIZECOLOR: EditVars.ResizeColor = i; break; case SET1_T_MOUSEDCLICKSPEED: EditVars.MouseDoubleClickSpeed = i; break; case SET1_T_MOUSESPEED: SetMouseSpeed( i ); break; case SET1_T_MOUSEREPEATDELAY: EditVars.MouseRepeatDelay = i; break; case SET1_T_CURRENTSTATUSCOLUMN: EditVars.CurrentStatusColumn = i; InitMenu(); break; case SET1_T_ENDOFLINECHAR: EditVars.EndOfLineChar = i; break; case SET1_T_EXITATTR: EditVars.ExitAttr = (char) i; break; case SET1_T_INACTIVEWINDOWCOLOR: EditVars.InactiveWindowColor = i; break; case SET1_T_TABAMOUNT: EditVars.TabAmount = i; break; case SET1_T_SHIFTWIDTH: EditVars.ShiftWidth = i; break; case SET1_T_PAGELINESEXPOSED: EditVars.PageLinesExposed = i; break; case SET1_T_HARDTAB: EditVars.HardTab = i; redisplay = TRUE; break; case SET1_T_STACKK: if( EditFlags.Starting ) { EditVars.StackK = i; } break; case SET1_T_LINENUMWINWIDTH: EditVars.LineNumWinWidth = i; break; case SET1_T_MAXWINDOWTILEX: EditVars.MaxWindowTileX = i; break; case SET1_T_MAXWINDOWTILEY: EditVars.MaxWindowTileY = i; break; case SET1_T_MAXSWAPK: SwapBlockInit( i ); break; case SET1_T_MAXEMSK: #ifndef NOEMS EMSBlockInit( i ); #endif break; case SET1_T_MAXXMSK: #ifndef NOXMS XMSBlockInit( i ); #endif break; case SET1_T_MAXFILTERHISTORY: FilterHistInit( i ); break; case SET1_T_MAXCLHISTORY: CLHistInit( i ); break; case SET1_T_MAXFINDHISTORY: FindHistInit( i ); break; case SET1_T_MAXLASTFILESHISTORY: LastFilesHistInit( i ); break; case SET1_T_MAXTILECOLORS: k = (EditVars.TileColors == NULL) ? 0 : EditVars.MaxTileColors + 1; EditVars.MaxTileColors = i; EditVars.TileColors = MemReAlloc( EditVars.TileColors, sizeof( type_style ) * ( EditVars.MaxTileColors + 1 ) ); for( ; k <= EditVars.MaxTileColors; ++k ) { EditVars.TileColors[k].foreground = -1; EditVars.TileColors[k].background = -1; EditVars.TileColors[k].font = -1; } break; case SET1_T_CLOCKX: EditVars.ClockX = i; GetClockStart(); break; case SET1_T_CLOCKY: EditVars.ClockY = i; GetClockStart(); break; case SET1_T_SPINX: EditVars.SpinX = i; GetSpinStart(); break; case SET1_T_SPINY: EditVars.SpinY = i; GetSpinStart(); break; case SET1_T_MAXLINELEN: /* file save fails if 1 line is > MAX_IO_BUFFER */ i = __min( i, MAX_IO_BUFFER ); EditVars.MaxLine = i; StaticStart(); WorkLine = MemReAlloc( WorkLine, sizeof( line ) + EditVars.MaxLine + 2 ); break; case SET1_T_TOOLBARBUTTONHEIGHT: EditVars.ToolBarButtonHeight = i; #ifdef __WIN__ ResizeRoot(); #endif break; case SET1_T_TOOLBARBUTTONWIDTH: EditVars.ToolBarButtonWidth = i; #ifdef __WIN__ ResizeRoot(); #endif break; case SET1_T_TOOLBARCOLOR: EditVars.ToolBarColor = i; #ifdef __WIN__ if( GetToolbarWindow() != NULL ) { InvalidateRect( GetToolbarWindow(), NULL, TRUE ); UpdateWindow( GetToolbarWindow() ); } #endif break; default: return( ERR_INVALID_SET_COMMAND ); } if( msgFlag ) { MySprintf( fn, "%s set to %d", GetTokenStringCVT( SetTokens1, j, settokstr, TRUE ), i ); } break; } } if( msgFlag && rc == ERR_NO_ERR && !EditFlags.Quiet ) { setMessage( fn, redisplay ); rc = DO_NOT_CLEAR_MESSAGE_WINDOW; } if( rc == ERR_NO_ERR && toggle ) { strcpy( value, save ); } return( rc ); #endif /* VICOMP */ } /* processSetToken */
/* * doInitializeEditor - do just that */ static void doInitializeEditor( int argc, char *argv[] ) { int i, arg, cnt, ocnt, startcnt = 0; srcline sline; int k, j; char tmp[FILENAME_MAX], c[1]; char buff[MAX_STR], file[MAX_STR], **list; char cmd[MAX_STR * 2]; char *parm; char *startup[MAX_STARTUP]; char *startup_parms[MAX_STARTUP]; vi_rc rc; vi_rc rc1; /* * Make sure WATCOM is setup and if it is not, make a best guess. */ watcom_setup_env(); /* * If EDPATH is not set, use system default %WATCOM%\EDDAT. */ if( getenv( "EDPATH" ) == NULL ) { char *watcom; watcom = getenv( "WATCOM" ); if( watcom != NULL ) { char edpath[FILENAME_MAX]; sprintf( edpath, "%s%c%s", watcom, FILE_SEP, "eddat" ); if( setenv( "EDPATH", edpath, 0 ) != 0 ) { /* * Bail out silently on error, as we will get error message later on. */ } } } /* * misc. set up */ MaxMemFree = MemSize(); StaticStart(); FTSInit(); BoundDataInit(); EditFlags.Starting = true; InitCommandLine(); ChkExtendedKbd(); SSInitBeforeConfig(); GetCWD1( &HomeDirectory ); GetCWD1( &CurrentDirectory ); SetCWD( HomeDirectory ); if( cfgFN == NULL ){ cfgFN = DupString( CFG_NAME ); } checkFlags( &argc, argv, startup, startup_parms, &startcnt ); ScreenInit(); SetWindowSizes(); EditFlags.ClockActive = false; SetInterrupts(); #ifdef __WIN__ InitClrPick(); InitFtPick(); SubclassGenericInit(); CursorOp( COP_INIT ); #else InitColors(); #endif InitSavebufs(); InitKeyMaps(); /* * initial configuration */ EditVars.Majick = MemStrDup( "()~@" ); EditVars.FileEndString = MemStrDup( "[END_OF_FILE]" ); MatchInit(); SetGadgetString( NULL ); WorkLine = MemAlloc( sizeof( line ) + EditVars.MaxLine + 2 ); WorkLine->len = -1; sline = 0; if( cfgFN[0] != 0 ) { c[0] = 0; rc = Source( cfgFN, c, &sline ); if( rc == ERR_FILE_NOT_FOUND ) { #ifdef __WIN__ CloseStartupDialog(); MessageBox( (HWND)NULLHANDLE, "Could not locate configuration information; please make sure your EDPATH environment variable is set correctly", EditorName, MB_OK ); ExitEditor( -1 ); #else rc = ERR_NO_ERR; #endif } } else { rc = ERR_NO_ERR; } if( wantNoReadEntireFile ) { EditFlags.ReadEntireFile = false; } VerifyTmpDir(); while( LostFileCheck() ); HookScriptCheck(); if( EditFlags.Quiet ) { EditFlags.Spinning = false; EditFlags.Clock = false; } ExtendedMemoryInit(); /* * more misc. setup */ if( EditVars.WordDefn == NULL ) { EditVars.WordDefn = DupString( &WordDefnDefault[6] ); InitWordSearch( EditVars.WordDefn ); } if( EditVars.WordAltDefn == NULL ) { EditVars.WordAltDefn = DupString( WordDefnDefault ); } if( EditVars.TagFileName == NULL ) { EditVars.TagFileName = DupString( "tags" ); } DotBuffer = MemAlloc( (maxdotbuffer + 2) * sizeof( vi_key ) ); AltDotBuffer = MemAlloc( (maxdotbuffer + 2) * sizeof( vi_key ) ); DotCmd = MemAlloc( (maxdotbuffer + 2) * sizeof( vi_key ) ); SwapBlockInit( EditVars.MaxSwapBlocks ); ReadBuffer = MemAlloc( MAX_IO_BUFFER + 6 ); WriteBuffer = MemAlloc( MAX_IO_BUFFER + 6 ); FindHistInit( EditVars.FindHist.max ); FilterHistInit( EditVars.FilterHist.max ); CLHistInit( EditVars.CLHist.max ); LastFilesHistInit( EditVars.LastFilesHist.max ); GetClockStart(); GetSpinStart(); SelRgnInit(); SSInitAfterConfig(); #if defined( VI_RCS ) ViRCSInit(); #endif /* * create windows */ StartWindows(); InitMouse(); rc1 = NewMessageWindow(); if( rc1 != ERR_NO_ERR ) { FatalError( rc1 ); } DoVersion(); rc1 = InitMenu(); if( rc1 != ERR_NO_ERR ) { FatalError( rc1 ); } EditFlags.SpinningOurWheels = true; EditFlags.ClockActive = true; EditFlags.DisplayHold = true; rc1 = NewStatusWindow(); if( rc1 != ERR_NO_ERR ) { FatalError( rc1 ); } EditFlags.DisplayHold = false; MaxMemFreeAfterInit = MemSize(); /* * look for a tag: if there is one, set it up as the file to start */ EditFlags.WatchForBreak = true; if( cTag != NULL && !EditFlags.NoInitialFileLoad ) { #if defined( __NT__ ) && !defined( __WIN__ ) { if( !EditFlags.Quiet ) { SetConsoleActiveScreenBuffer( OutputHandle ); } } #endif rc1 = LocateTag( cTag, file, buff ); cFN = file; if( rc1 != ERR_NO_ERR ) { if( rc1 == ERR_TAG_NOT_FOUND ) { Error( GetErrorMsg( rc1 ), cTag ); ExitEditor( 0 ); } FatalError( rc1 ); } } /* * start specified file(s) */ cmd[0] = 'e'; cmd[1] = 0; arg = argc - 1; k = 1; while( !EditFlags.NoInitialFileLoad ) { if( cFN == nullFN && !EditFlags.UseNoName ) { break; } #ifdef __NT__ { int k2; int arg2; char path[_MAX_PATH]; int found; int fd; size_t len; size_t len1; char *p; /* * check for the existence of a file name containing spaces, and open it if * there is one */ len = _MAX_PATH - 1; found = 0; p = path; arg2 = arg; for( k2 = k; argv[k2] != NULL; ) { len1 = strlen( argv[k2] ); if( len1 > len ) break; memcpy( p, argv[k2], len1 ); p += len1; *p = '\0'; len -= len1; --arg2; ++k2; fd = open( path, O_RDONLY ); if( fd != -1 ) { close( fd ); k = k2; arg = arg2; found = 1; break; } *p++ = ' '; } if( found ) { #ifndef __UNIX__ len1 = strlen( path ); if( path[len1 - 1] == '.' ) path[len1 - 1] = '\0'; #endif rc1 = NewFile( path, false ); if( rc1 != ERR_NO_ERR ) { FatalError( rc1 ); } cFN = argv[k]; if( arg < 1 ) { break; } continue; } } #endif strcat( cmd, SingleBlank ); strcat( cmd, cFN ); ocnt = cnt = ExpandFileNames( cFN, &list ); if( cnt == 0 ) { cnt = 1; } else { cFN = list[0]; } for( j = 0; j < cnt; j++ ) { rc1 = NewFile( cFN, false ); if( rc1 != ERR_NO_ERR && rc1 != NEW_FILE ) { FatalError( rc1 ); } if( EditFlags.BreakPressed ) { break; } if( cnt > 0 && j < cnt - 1 ) { cFN = list[j + 1]; } } if( ocnt > 0 ) { MemFreeList( ocnt, list ); } if( EditFlags.BreakPressed ) { ClearBreak(); break; } k++; arg--; if( cTag != NULL || arg < 1 ) { break; } cFN = argv[k]; } if( EditFlags.StdIOMode ) { rc1 = NewFile( "stdio", false ); if( rc1 != ERR_NO_ERR ) { FatalError( rc1 ); } } EditFlags.WatchForBreak = false; EditFlags.Starting = false; /* * if there was a tag, do the appropriate search */ if( cTag != NULL && !EditFlags.NoInitialFileLoad ) { if( buff[0] != '/' ) { i = atoi( buff ); rc1 = GoToLineNoRelCurs( i ); } else { rc1 = FindTag( buff ); } if( rc1 > 0 ) { Error( GetErrorMsg( rc1 ) ); } } /* * try to run startup file */ if( EditFlags.RecoverLostFiles ) { startcnt = 0; } for( i = 0; i < startcnt; i++ ) { GetFromEnv( startup[i], tmp ); ReplaceString( &cfgFN, tmp ); if( cfgFN[0] != 0 ) { if( startup_parms[i] != NULL ) { parm = startup_parms[i]; } else { c[0] = 0; parm = c; } #if defined( __NT__ ) && !defined( __WIN__ ) { if( !EditFlags.Quiet ) { SetConsoleActiveScreenBuffer( OutputHandle ); } } #endif sline = 0; rc = Source( cfgFN, parm, &sline ); } } if( rc > ERR_NO_ERR ) { Error( "%s on line %u of \"%s\"", GetErrorMsg( rc ), sline, cfgFN ); } if( argc == 1 ) { LoadHistory( NULL ); } else { LoadHistory( cmd ); } if( EditVars.GrepDefault == NULL ) { EditVars.GrepDefault = DupString( "*.(c|h)" ); } if( goCmd[0] != 0 ) { KeyAddString( goCmd ); } if( keysToPush != NULL ) { KeyAddString( keysToPush ); } #ifdef __WIN__ if( lineToGoTo != 0 ) { SetCurrentLine( lineToGoTo ); NewCursor( CurrentWindow, EditVars.NormalCursorType ); } #endif AutoSaveInit(); HalfPageLines = WindowAuxInfo( CurrentWindow, WIND_INFO_TEXT_LINES ) / 2 - 1; #if defined( _M_X64 ) VarAddGlobalStr( "OSX64", "1" ); #elif defined( _M_IX86 ) && !defined( _M_I86 ) VarAddGlobalStr( "OS386", "1" ); #endif if( EditVars.StatusString == NULL ) { EditVars.StatusString = DupString( "L:$6L$nC:$6C" ); } UpdateStatusWindow(); #ifdef __WIN__ if( CurrentInfo == NULL ) { // no file loaded - screen is disconcertenly empty - reassure DisplayFileStatus(); } #endif NewCursor( CurrentWindow, EditVars.NormalCursorType ); #if defined( __NT__ ) && !defined( __WIN__ ) { SetConsoleActiveScreenBuffer( OutputHandle ); } #endif } /* doInitializeEditor */