Skip to content

Commit

Permalink
Add fexpand_esc to specify escape char or quote char for spaces
Browse files Browse the repository at this point in the history
in filenames output by fexpand.
Not yet user selectable; defaults to quotes on Windows and
backslash on everything else.
  • Loading branch information
gwsw committed Feb 20, 2024
1 parent 4cee0c0 commit d1e1111
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
33 changes: 21 additions & 12 deletions filename.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ extern int ctldisp;
extern int utf_mode;
extern IFILE curr_ifile;
extern IFILE old_ifile;
extern char *fexpand_esc;
#if SPACES_IN_FILENAMES
extern char openquote;
extern char closequote;
Expand Down Expand Up @@ -300,20 +301,28 @@ static void xcpy_char(xcpy *xp, char ch)

static void xcpy_filename(xcpy *xp, constant char *str)
{
#if MSDOS_COMPILER
lbool need_quotes = (strchr(str, ' ') != NULL);
if (need_quotes) xcpy_char(xp, '"');
for (; *str != '\0'; str++)
xcpy_char(xp, *str);
if (need_quotes) xcpy_char(xp, '"');
#else
for (; *str != '\0'; str++)
char quote = '\0';
if (strcmp(fexpand_esc, "quote") == 0)
quote = '"';
else if (strcmp(fexpand_esc, "squote") == 0)
quote = '\'';
if (quote != '\0')
{
lbool need_quotes = (strchr(str, ' ') != NULL);
if (need_quotes) xcpy_char(xp, quote);
for (; *str != '\0'; str++)
xcpy_char(xp, *str);
if (need_quotes) xcpy_char(xp, quote);
} else
{
if (*str == ' ')
xcpy_char(xp, '\\');
xcpy_char(xp, *str);
char esc = (fexpand_esc[0] == '1') ? '\\' : fexpand_esc[0];
for (; *str != '\0'; str++)
{
if (*str == ' ')
xcpy_char(xp, esc);
xcpy_char(xp, *str);
}
}
#endif /* MSDOS_COMPILER */
}

static size_t fexpand_copy(constant char *fr, char *to)
Expand Down
5 changes: 5 additions & 0 deletions opttbl.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ public int proc_return; /* Special handling of carriage return */
public int match_shift; /* Extra horizontal shift on search match */
public long match_shift_fraction = NUM_FRAC_DENOM/2; /* 1/2 of screen width */
public char intr_char = CONTROL('X'); /* Char to interrupt reads */
#if MSDOS_COMPILER
public char *fexpand_esc = "quote";
#else
public char *fexpand_esc = "\\";
#endif
#if HILITE_SEARCH
public int hilite_search; /* Highlight matched search patterns? */
#endif
Expand Down

0 comments on commit d1e1111

Please sign in to comment.