Skip to content

Commit

Permalink
Whitespace rationalisation of entire code base.
Browse files Browse the repository at this point in the history
The number of people has been steadily increasing who read our source
code with an editor that thinks tab stops are 4 spaces apart, as
opposed to the traditional tty-derived 8 that the PuTTY code expects.

So I've been wondering for ages about just fixing it, and switching to
a spaces-only policy throughout the code. And I recently found out
about 'git blame -w', which should make this change not too disruptive
for the purposes of source-control archaeology; so perhaps now is the
time.

While I'm at it, I've also taken the opportunity to remove all the
trailing spaces from source lines (on the basis that git dislikes
them, and is the only thing that seems to have a strong opinion one
way or the other).
    
Apologies to anyone downstream of this code who has complicated patch
sets to rebase past this change. I don't intend it to be needed again.
  • Loading branch information
sgtatham committed Sep 8, 2019
1 parent b60230d commit 5d718ef
Show file tree
Hide file tree
Showing 210 changed files with 31,845 additions and 31,845 deletions.
2 changes: 1 addition & 1 deletion Recipe
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- makefile -*-
#
#
# This file describes which PuTTY programs are made up from which
# object and resource files. It is processed into the various
# Makefiles by means of a Perl script. Makefile changes should
Expand Down
26 changes: 13 additions & 13 deletions charset/charset.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
* character sets known to this library.
*/
typedef enum {
CS_NONE, /* used for reporting errors, etc */
CS_NONE, /* used for reporting errors, etc */
CS_ISO8859_1,
CS_ISO8859_1_X11, /* X font encoding with VT100 glyphs */
CS_ISO8859_1_X11, /* X font encoding with VT100 glyphs */
CS_ISO8859_2,
CS_ISO8859_3,
CS_ISO8859_4,
Expand Down Expand Up @@ -77,7 +77,7 @@ typedef struct {

/*
* Routine to convert a MB/SB character set to Unicode.
*
*
* This routine accepts some number of bytes, updates a state
* variable, and outputs some number of Unicode characters. There
* are no guarantees. You can't even guarantee that at most one
Expand All @@ -86,12 +86,12 @@ typedef struct {
* then you suddenly see FE. Now you need to output _two_ error
* characters - one for the incomplete sequence E1 80, and one for
* the completely invalid UTF-8 byte FE.
*
*
* Returns the number of wide characters output; will never output
* more than the size of the buffer (as specified on input).
* Advances the `input' pointer and decrements `inlen', to indicate
* how far along the input string it got.
*
*
* The sequence of `errlen' wide characters pointed to by `errstr'
* will be used to indicate a conversion error. If `errstr' is
* NULL, `errlen' will be ignored, and the library will choose
Expand All @@ -101,21 +101,21 @@ typedef struct {

int charset_to_unicode(const char **input, int *inlen,
wchar_t *output, int outlen,
int charset, charset_state *state,
const wchar_t *errstr, int errlen);
int charset, charset_state *state,
const wchar_t *errstr, int errlen);

/*
* Routine to convert Unicode to an MB/SB character set.
*
*
* This routine accepts some number of Unicode characters, updates
* a state variable, and outputs some number of bytes.
*
*
* Returns the number of bytes characters output; will never output
* more than the size of the buffer (as specified on input), and
* will never output a partial MB character. Advances the `input'
* pointer and decrements `inlen', to indicate how far along the
* input string it got.
*
*
* The sequence of `errlen' characters pointed to by `errstr' will
* be used to indicate a conversion error. If `errstr' is NULL,
* `errlen' will be ignored, and the library will choose something
Expand All @@ -125,8 +125,8 @@ int charset_to_unicode(const char **input, int *inlen,

int charset_from_unicode(const wchar_t **input, int *inlen,
char *output, int outlen,
int charset, charset_state *state,
const char *errstr, int errlen);
int charset, charset_state *state,
const char *errstr, int errlen);

/*
* Convert X11 encoding names to and from our charset identifiers.
Expand All @@ -152,6 +152,6 @@ int charset_localenc_nth(int n);
* Convert Mac OS script/region/font to our charset identifiers.
*/
int charset_from_macenc(int script, int region, int sysvers,
const char *fontname);
const char *fontname);

#endif /* charset_charset_h */
4 changes: 2 additions & 2 deletions charset/enum.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*
* enum.c - enumerate all charsets defined by the library.
*
*
* This file maintains a list of every other source file which
* contains ENUM_CHARSET definitions. It #includes each one with
* ENUM_CHARSETS defined, which causes those source files to do
* nothing at all except call the ENUM_CHARSET macro on each
* charset they define.
*
*
* This file in turn is included from various other places, with
* the ENUM_CHARSET macro defined to various different things. This
* allows us to have multiple implementations of the master charset
Expand Down
66 changes: 33 additions & 33 deletions charset/fromucs.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,29 @@ static void charset_emit(void *ctx, long int output)
int outlen;

if (output == ERROR) {
p = param->errstr;
outlen = param->errlen;
p = param->errstr;
outlen = param->errlen;
} else {
outval = output;
p = &outval;
outlen = 1;
outval = output;
p = &outval;
outlen = 1;
}

if (param->outlen >= outlen) {
while (outlen > 0) {
*param->output++ = *p++;
param->outlen--;
outlen--;
}
while (outlen > 0) {
*param->output++ = *p++;
param->outlen--;
outlen--;
}
} else {
param->stopped = 1;
param->stopped = 1;
}
}

int charset_from_unicode(const wchar_t **input, int *inlen,
char *output, int outlen,
int charset, charset_state *state,
const char *errstr, int errlen)
int charset, charset_state *state,
const char *errstr, int errlen)
{
charset_spec const *spec = charset_find_spec(charset);
charset_state localstate;
Expand All @@ -57,36 +57,36 @@ int charset_from_unicode(const wchar_t **input, int *inlen,
* charset_emit will expect a valid errstr.
*/
if (!errstr) {
/* *shrug* this is good enough, and consistent across all SBCS... */
param.errstr = ".";
param.errlen = 1;
/* *shrug* this is good enough, and consistent across all SBCS... */
param.errstr = ".";
param.errlen = 1;
}
param.errstr = errstr;
param.errlen = errlen;

if (!state) {
localstate.s0 = 0;
localstate.s0 = 0;
} else {
localstate = *state; /* structure copy */
localstate = *state; /* structure copy */
}
state = &localstate;

while (*inlen > 0) {
int lenbefore = param.output - output;
spec->write(spec, **input, &localstate, charset_emit, &param);
if (param.stopped) {
/*
* The emit function has _tried_ to output some
* characters, but ran up against the end of the
* buffer. Leave immediately, and return what happened
* _before_ attempting to process this character.
*/
return lenbefore;
}
if (state)
*state = localstate; /* structure copy */
(*input)++;
(*inlen)--;
int lenbefore = param.output - output;
spec->write(spec, **input, &localstate, charset_emit, &param);
if (param.stopped) {
/*
* The emit function has _tried_ to output some
* characters, but ran up against the end of the
* buffer. Leave immediately, and return what happened
* _before_ attempting to process this character.
*/
return lenbefore;
}
if (state)
*state = localstate; /* structure copy */
(*input)++;
(*inlen)--;
}
return param.output - output;
}
22 changes: 11 additions & 11 deletions charset/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
#define lenof(x) ( sizeof((x)) / sizeof(*(x)) )

/* This is an invalid Unicode value used to indicate an error. */
#define ERROR 0xFFFFL /* Unicode value representing error */
#define ERROR 0xFFFFL /* Unicode value representing error */

typedef struct charset_spec charset_spec;
typedef struct sbcs_data sbcs_data;

struct charset_spec {
int charset; /* numeric identifier */
int charset; /* numeric identifier */

/*
* A function to read the character set and output Unicode
Expand All @@ -24,17 +24,17 @@ struct charset_spec {
* on the input.
*/
void (*read)(charset_spec const *charset, long int input_chr,
charset_state *state,
void (*emit)(void *ctx, long int output), void *emitctx);
charset_state *state,
void (*emit)(void *ctx, long int output), void *emitctx);
/*
* A function to read Unicode characters and output in this
* character set. The `emit' function expects to get byte
* values passed to it; it should be sent ERROR for any
* non-representable characters on the input.
*/
void (*write)(charset_spec const *charset, long int input_chr,
charset_state *state,
void (*emit)(void *ctx, long int output), void *emitctx);
charset_state *state,
void (*emit)(void *ctx, long int output), void *emitctx);
void const *data;
};

Expand All @@ -60,7 +60,7 @@ struct sbcs_data {
* position in this table, you branch according to whether
* sbcs2ucs[ucs2sbcs[X]] is less than, greater than, or equal
* to U.
*
*
* Note that since there may be fewer than 256 valid byte
* values in a particular SBCS, we must supply the length of
* this table as well as the contents.
Expand All @@ -74,11 +74,11 @@ struct sbcs_data {
*/
charset_spec const *charset_find_spec(int charset);
void read_sbcs(charset_spec const *charset, long int input_chr,
charset_state *state,
void (*emit)(void *ctx, long int output), void *emitctx);
charset_state *state,
void (*emit)(void *ctx, long int output), void *emitctx);
void write_sbcs(charset_spec const *charset, long int input_chr,
charset_state *state,
void (*emit)(void *ctx, long int output), void *emitctx);
charset_state *state,
void (*emit)(void *ctx, long int output), void *emitctx);

/*
* Placate compiler warning about unused parameters, of which we
Expand Down
40 changes: 20 additions & 20 deletions charset/localenc.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* announcing what character set it will be using), and a set of
* enumeration functions which return a list of supported
* encodings one by one.
*
*
* charset_from_localenc will attempt all other text translations
* as well as this table, to maximise the number of different ways
* you can select a supported charset.
Expand Down Expand Up @@ -83,44 +83,44 @@ const char *charset_to_localenc(int charset)
int i;

for (i = 0; i < (int)lenof(localencs); i++)
if (charset == localencs[i].charset)
return localencs[i].name;
if (charset == localencs[i].charset)
return localencs[i].name;

return NULL; /* not found */
return NULL; /* not found */
}

int charset_from_localenc(const char *name)
{
int i;

if ( (i = charset_from_mimeenc(name)) != CS_NONE)
return i;
return i;
if ( (i = charset_from_xenc(name)) != CS_NONE)
return i;
return i;

for (i = 0; i < (int)lenof(localencs); i++) {
const char *p, *q;
p = name;
q = localencs[i].name;
while (*p || *q) {
if (tolower((unsigned char)*p) != tolower((unsigned char)*q))
break;
p++; q++;
}
if (!*p && !*q)
return localencs[i].charset;
const char *p, *q;
p = name;
q = localencs[i].name;
while (*p || *q) {
if (tolower((unsigned char)*p) != tolower((unsigned char)*q))
break;
p++; q++;
}
if (!*p && !*q)
return localencs[i].charset;
}

return CS_NONE; /* not found */
return CS_NONE; /* not found */
}

int charset_localenc_nth(int n)
{
int i;

for (i = 0; i < (int)lenof(localencs); i++)
if (localencs[i].return_in_enum && !n--)
return localencs[i].charset;
if (localencs[i].return_in_enum && !n--)
return localencs[i].charset;

return CS_NONE; /* end of list */
return CS_NONE; /* end of list */
}
Loading

0 comments on commit 5d718ef

Please sign in to comment.