Skip to content

Commit

Permalink
vi: use const character pointer when possible
Browse files Browse the repository at this point in the history
  • Loading branch information
jmalak committed Aug 4, 2024
1 parent 98b0615 commit ea09c76
Show file tree
Hide file tree
Showing 48 changed files with 411 additions and 403 deletions.
4 changes: 2 additions & 2 deletions bld/vi/c/autosave.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*
* Open Watcom Project
*
* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved.
* Copyright (c) 2002-2024 The Open Watcom Contributors. All Rights Reserved.
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
Expand Down Expand Up @@ -108,7 +108,7 @@ void GetCurrentFilePath( char *path )
/*
* getTmpName - get tmp name in path
*/
static void getTmpName( char *path, char *tmpname )
static void getTmpName( const char *path, char *tmpname )
{
char tmp[FILENAME_MAX];
int i;
Expand Down
8 changes: 4 additions & 4 deletions bld/vi/c/clset.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ static bool msgFlag;
static bool needsRedisplay = false;
static char msgString[MAX_STR];

static void setMessage( char *msg, bool redisplay )
static void setMessage( const char *msg, bool redisplay )
{
strcpy( msgString, msg );
needsRedisplay = redisplay;
Expand Down Expand Up @@ -1133,7 +1133,7 @@ static size_t getLongestTokenLength( const char *list )
/*
* getSetInfo - build string of values
*/
static list_linenum getSetInfo( char ***vals, char ***list, size_t *longest )
static list_linenum getSetInfo( const char ***vals, char ***list, size_t *longest )
{
list_linenum i;
size_t i1;
Expand All @@ -1150,7 +1150,7 @@ static list_linenum getSetInfo( char ***vals, char ***list, size_t *longest )
tc = tc1 + tc2;
sdata = _MemAllocPtrArray( set_data, tc );
*list = _MemAllocPtrArray( char, tc );
*vals = _MemAllocPtrArray( char, tc );
*vals = (const char **)_MemAllocPtrArray( char, tc );

for( i1 = 0; i1 < tc1; i1++ ) {
sdata[i1] = MemAlloc( sizeof( set_data ) );
Expand Down Expand Up @@ -1197,7 +1197,7 @@ vi_rc Set( const char *name )
short tmp;
list_linenum tc;
list_linenum i;
char **vals = NULL;
const char **vals = NULL;
char **list;
size_t longest;
#endif
Expand Down
8 changes: 4 additions & 4 deletions bld/vi/c/clsubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,12 @@ static void nextSearchStartPos( i_mark *pos, bool gflag, int rlen )
/*
* ReplaceSubString - replace a sub-string with a different one
*/
int ReplaceSubString( char *data, int len, int s, int e, char *rep, int replen )
int ReplaceSubString( char *data, int len, int s, int e, const char *replace, int rlen )
{
int i, ln, delta, slen;

slen = e - s + 1;
delta = slen - replen;
delta = slen - rlen;

/*
* make room
Expand All @@ -220,8 +220,8 @@ int ReplaceSubString( char *data, int len, int s, int e, char *rep, int replen )
/*
* copy in new string
*/
for( i = 0; i < replen; i++ ) {
data[s + i] = rep[i];
for( i = 0; i < rlen; i++ ) {
data[s + i] = replace[i];
}
return( len );

Expand Down
4 changes: 2 additions & 2 deletions bld/vi/c/cstatus.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*
* Open Watcom Project
*
* Copyright (c) 2015-2016 The Open Watcom Contributors. All Rights Reserved.
* Copyright (c) 2015-2024 The Open Watcom Contributors. All Rights Reserved.
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
Expand Down Expand Up @@ -36,7 +36,7 @@
#include "win.h"

#define MAX_CSTATUS_STRLEN 10
static char *currStatus[] =
static const char * const currStatus[] =
{
"change",
"delete",
Expand Down
4 changes: 2 additions & 2 deletions bld/vi/c/dc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*
* Open Watcom Project
*
* Copyright (c) 2015-2022 The Open Watcom Contributors. All Rights Reserved.
* Copyright (c) 2015-2024 The Open Watcom Contributors. All Rights Reserved.
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
Expand Down Expand Up @@ -440,7 +440,7 @@ dc_line *DCFindLine( int c_line_no, window_id wid )
return( NULL );
}

void DCValidateLine( dc_line *dcline, int start_col, char *text )
void DCValidateLine( dc_line *dcline, int start_col, const char *text )
{
size_t nlen;

Expand Down
8 changes: 4 additions & 4 deletions bld/vi/c/edbind.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ static void Banner( void )
/*
* Abort - made a boo-boo
*/
static void Abort( char *str, ... )
static void Abort( const char *str, ... )
{
va_list args;

Expand All @@ -94,7 +94,7 @@ static void Abort( char *str, ... )
/*
* MyPrintf - do a printf
*/
static void MyPrintf( char *str, ... )
static void MyPrintf( const char *str, ... )
{
va_list args;

Expand Down Expand Up @@ -142,7 +142,7 @@ static int copy_file( FILE *src, FILE *dst, unsigned long tocopy )
/*
* AddDataToEXE - tack data to end of an EXE
*/
static void AddDataToEXE( char *exe, char *outexe, char *data, bind_size data_len, struct stat *fs )
static void AddDataToEXE( const char *exe, const char *outexe, char *data, bind_size data_len, struct stat *fs )
{
FILE *fp;
FILE *newfp;
Expand Down Expand Up @@ -273,7 +273,7 @@ static FILE *GetFromEnvAndOpen( const char *inpath )
#if defined( __WATCOMC__ )
#pragma aux Usage __aborts
#endif
static void Usage( char *msg )
static void Usage( const char *msg )
{
if( msg != NULL ) {
printf( "%s\n", msg );
Expand Down
10 changes: 5 additions & 5 deletions bld/vi/c/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*
* Open Watcom Project
*
* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved.
* Copyright (c) 2002-2024 The Open Watcom Contributors. All Rights Reserved.
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
Expand Down Expand Up @@ -319,11 +319,11 @@ static size_t getFileInfoString( char *st, bool is_small )
return( strlen( st ) );
}

static void make_short_name( char *name, size_t len, char *buffer )
static void make_short_name( const char *name, size_t len, char *buffer )
{
char *start;
char *end;
size_t newlen;
const char *start;
const char *end;
size_t newlen;

len -= 2; /* for 2 quotes */
strcpy( buffer, SingleDQuote );
Expand Down
4 changes: 2 additions & 2 deletions bld/vi/c/filelast.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*
* Open Watcom Project
*
* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved.
* Copyright (c) 2002-2024 The Open Watcom Contributors. All Rights Reserved.
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
Expand Down Expand Up @@ -42,7 +42,7 @@
/*
* UpdateLastFilesList - update the list of the last files edited
*/
void UpdateLastFilesList( char *fname )
void UpdateLastFilesList( const char *fname )
{
history_data *h;
int i;
Expand Down
2 changes: 1 addition & 1 deletion bld/vi/c/fini.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
#define T2 "\t\t"
#endif

char * UsageMsg[] = {
const char * const UsageMsg[] = {
#ifdef __WIN__
"viw [-?-dinqrvzI] +<n> -k\"keys\" [-s<scr> [-p\"prm\"]] [-t<tag>]",
" [-c<cfg>] [-P<x y w h>] files",
Expand Down
4 changes: 2 additions & 2 deletions bld/vi/c/fts.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*
* Open Watcom Project
*
* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved.
* Copyright (c) 2002-2024 The Open Watcom Contributors. All Rights Reserved.
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
Expand Down Expand Up @@ -74,7 +74,7 @@ vi_rc FTSStart( const char *data )

} /* FTSStart */

static char *expandTokenSet( char *token_no, char *buff )
static char *expandTokenSet( const char *token_no, char *buff )
{
bool val;
int tok;
Expand Down
8 changes: 4 additions & 4 deletions bld/vi/c/help.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*
* Open Watcom Project
*
* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved.
* Copyright (c) 2002-2024 The Open Watcom Contributors. All Rights Reserved.
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
Expand Down Expand Up @@ -52,13 +52,13 @@
pick( "SETtings", "set.hlp" ) \
pick( "STARTing", "start.hlp" )

static char HelpCmdTokens[] = {
static char const HelpCmdTokens[] = {
#define pick(t,h) t "\0"
HELPCMDS()
#undef pick
};

char *helpFiles[] = {
const char * const helpFiles[] = {
#define pick(t,h) h,
HELPCMDS()
#undef pick
Expand Down Expand Up @@ -115,7 +115,7 @@ vi_rc DoHelpOnContext( void )

vi_rc DoHelp( const char *data )
{
char *hfile;
const char *hfile;
const char *tstr;
int token;
vi_rc rc;
Expand Down
6 changes: 3 additions & 3 deletions bld/vi/c/lang.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
#include "clibext.h"


#define PRAGMA_DATFILE "pragma.dat"
#define DECLSPEC_DATFILE "declspec.dat"

typedef struct vi_keyword {
vi_word keyword;
int hashValue;
Expand All @@ -56,9 +59,6 @@ static hash_entry *declspec_table = NULL;
static int declspec_table_entries = 0;
static char *declspec_read_buf = NULL;

#define PRAGMA_DATFILE "pragma.dat"
#define DECLSPEC_DATFILE "declspec.dat"

/*
* hashpjw - taken from red dragon book, pg 436
*/
Expand Down
12 changes: 5 additions & 7 deletions bld/vi/c/name.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*
* Open Watcom Project
*
* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved.
* Copyright (c) 2002-2024 The Open Watcom Contributors. All Rights Reserved.
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
Expand Down Expand Up @@ -33,13 +33,11 @@
#include "vi.h"
#include "banner.h"

#if defined( __WIN__ )
# if defined( __OS2__ )
#if !defined( __WIN__ )
const char _NEAR BANNER1[] = banner1t( "Vi Text Editor" );
#elif defined( __OS2__ )
const char _NEAR BANNER1[] = banner1t( "Text Editor for OS/2 PM" );
# else
const char _NEAR BANNER1[] = banner1t( "Text Editor for Windows" );
# endif
#else
const char _NEAR BANNER1[] = banner1t( "Vi Text Editor" );
const char _NEAR BANNER1[] = banner1t( "Text Editor for Windows" );
#endif
const char _NEAR BANNER2[] = banner1v( _VI_VERSION_ );
2 changes: 1 addition & 1 deletion bld/vi/c/savebuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ void FiniSavebufs( void )
/*
* AddLineToSavebuf - add a single line to save buffer
*/
void AddLineToSavebuf( char *data, int scol, int ecol )
void AddLineToSavebuf( const char *data, int scol, int ecol )
{
savebuf *tmp;
int i, len, j;
Expand Down
4 changes: 2 additions & 2 deletions bld/vi/c/select.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*
* Open Watcom Project
*
* Copyright (c) 2002-2019 The Open Watcom Contributors. All Rights Reserved.
* Copyright (c) 2002-2024 The Open Watcom Contributors. All Rights Reserved.
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
Expand Down Expand Up @@ -143,7 +143,7 @@ vi_rc SelectItem( selectitem *si )
*/
vi_rc SelectItemAndValue( window_info *wi, char *title, char **list,
list_linenum maxlist, vi_rc (*updatertn)( const char *, char *, int * ),
size_t indent, char **vals, int valoff )
size_t indent, const char **vals, int valoff )
{
// list_linenum j;
file *cfile;
Expand Down
12 changes: 6 additions & 6 deletions bld/vi/c/sstyle.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*
* Open Watcom Project
*
* Copyright (c) 2015-2022 The Open Watcom Contributors. All Rights Reserved.
* Copyright (c) 2015-2024 The Open Watcom Contributors. All Rights Reserved.
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
Expand Down Expand Up @@ -45,7 +45,7 @@
type_style SEType[SE_MAXSIZE];


static void getEOFText( ss_block *ss_new, char *text )
static void getEOFText( ss_block *ss_new, const char *text )
{
if( *text ) {
ss_new->type = SE_EOFTEXT;
Expand All @@ -57,9 +57,9 @@ static void getEOFText( ss_block *ss_new, char *text )
}
}

static void getText( ss_block *ss_new, char *start )
static void getText( ss_block *ss_new, const char *start )
{
char *end = start;
const char *end = start;

if( *end == '\0' ) {
SSGetBeyondText( ss_new );
Expand All @@ -70,7 +70,7 @@ static void getText( ss_block *ss_new, char *start )
ss_new->len = end - start;
}

static void getNextBlock( ss_block *ss_new, char *text, int text_col,
static void getNextBlock( ss_block *ss_new, const char *text, int text_col,
line *line, linenum line_no )
{
/* unused parameters */ (void)line_no;
Expand Down Expand Up @@ -313,7 +313,7 @@ void SSGetWhiteSpace( ss_block *ss_new, const char *start )

// NOTE! for this to work ...
// ss_old must point the the head of a
void SSDifBlock( ss_block *ss_old, char *text, int start_col,
void SSDifBlock( ss_block *ss_old, const char *text, int start_col,
line *line, linenum line_no, int *dif )
{
ss_block ss_new, *ss_inc;
Expand Down
Loading

0 comments on commit ea09c76

Please sign in to comment.