Commit 466e7769 authored by Jeremy Huddleston's avatar Jeremy Huddleston

Whitespace cleanup from Thomas Dickey's luit-20100601 fork

Signed-off-by: Jeremy Huddleston's avatarJeremy Huddleston <jeremyhu@apple.com>
parent fddfe30c
This diff is collapsed.
......@@ -49,8 +49,8 @@ typedef struct _Charset {
const void *data;
int (*other_stack) (unsigned c, OtherStatePtr aux);
OtherState *other_aux;
unsigned int (*other_recode)(unsigned int c, OtherStatePtr aux);
unsigned int (*other_reverse)(unsigned int c, OtherStatePtr aux);
unsigned int (*other_recode) (unsigned int c, OtherStatePtr aux);
unsigned int (*other_reverse) (unsigned int c, OtherStatePtr aux);
struct _Charset *next;
} CharsetRec, *CharsetPtr;
......@@ -70,7 +70,7 @@ const CharsetRec *getCharset(unsigned, int);
const CharsetRec *getCharsetByName(const char *);
void reportCharsets(void);
int getLocaleState(const char *locale, const char *charset,
int *gl_return, int *gr_return,
int *gl_return, int *gr_return,
const CharsetRec * *g0_return,
const CharsetRec * *g1_return,
const CharsetRec * *g2_return,
......
This diff is collapsed.
......@@ -25,40 +25,40 @@ THE SOFTWARE.
#include "charset.h"
#define ESC 0x1B
#define CSI 0x9B
#define CSI_7 '['
#define SS2 0x8E
#define SS2_7 0x4E
#define SS3 0x8F
#define SS3_7 0x4F
#define LS0 0x0F
#define LS1 0x0E
#define LS2_7 0x6E
#define LS3_7 0x6F
#define ESC 0x1B
#define CSI 0x9B
#define CSI_7 '['
#define SS2 0x8E
#define SS2_7 0x4E
#define SS3 0x8F
#define SS3_7 0x4F
#define LS0 0x0F
#define LS1 0x0E
#define LS2_7 0x6E
#define LS3_7 0x6F
#define LS1R_7 0x7E
#define LS2R_7 0x7D
#define LS3R_7 0x7C
#define IS_FINAL_ESC(x) (((x) & 0xF0 ) != 0x20)
#define IS_FINAL_CSI(x) (((x) & 0xF0 ) != 0x20 && (((x) & 0xF0 ) != 0x30))
#define IS_FINAL_CSI(x) (((x) & 0xF0 ) != 0x20 && (((x) & 0xF0 ) != 0x30))
#define P_NORMAL 0
#define P_ESC 1
#define P_CSI 2
#define P_NORMAL 0
#define P_ESC 1
#define P_CSI 2
#define S_NORMAL 0
#define S_SS2 1
#define S_SS3 2
#define S_NORMAL 0
#define S_SS2 1
#define S_SS3 2
#define IF_SS 1
#define IF_LS 2
#define IF_SS 1
#define IF_LS 2
#define IF_EIGHTBIT 4
#define IF_SSGR 8
#define IF_SSGR 8
#define OF_SS 1
#define OF_LS 2
#define OF_SELECT 4
#define OF_SS 1
#define OF_LS 2
#define OF_SELECT 4
#define OF_PASSTHRU 8
typedef struct _Iso2022 {
......@@ -95,7 +95,7 @@ int mergeIso2022(Iso2022Ptr, Iso2022Ptr);
void reportIso2022(Iso2022Ptr);
void terminate(Iso2022Ptr, int);
void terminateEsc(Iso2022Ptr, int, unsigned char *, unsigned);
void copyIn(Iso2022Ptr, int, unsigned char*, int);
void copyIn(Iso2022Ptr, int, unsigned char *, int);
void copyOut(Iso2022Ptr, int, unsigned char *, unsigned);
#endif /* LUIT_ISO2022_H */
This diff is collapsed.
This diff is collapsed.
......@@ -59,15 +59,15 @@ typedef struct {
} aux_hkscs;
typedef struct {
FontMapPtr cs0_mapping; /* gb18030.2000-0 */
FontMapReversePtr cs0_reverse;
FontMapPtr cs0_mapping; /* gb18030.2000-0 */
FontMapReversePtr cs0_reverse;
FontMapPtr cs1_mapping; /* gb18030.2000-1 */
FontMapReversePtr cs1_reverse;
FontMapPtr cs1_mapping; /* gb18030.2000-1 */
FontMapReversePtr cs1_reverse;
int linear; /* set to '1' if stack_gb18030 linearized a 4bytes seq */
int buf[3];
int buf_ptr;
int linear; /* set to '1' if stack_gb18030 linearized a 4bytes seq */
int buf[3];
int buf_ptr;
} aux_gb18030;
typedef union {
......
......@@ -37,30 +37,30 @@ static char keyword[MAX_KEYWORD_LENGTH];
static void
skipEndOfLine(FILE *f, int c)
{
if(c == 0)
c = getc(f);
for(;;)
if(c <= 0 || c == '\n')
return;
else
c = getc(f);
if (c == 0)
c = getc(f);
for (;;)
if (c <= 0 || c == '\n')
return;
else
c = getc(f);
}
static int
drainWhitespace(FILE *f, int c)
{
if(c == 0)
c = getc(f);
if (c == 0)
c = getc(f);
while (c == '#' || c == ' ' || c == '\t') {
if(c <= 0)
return 0;
if(c == '#') {
skipEndOfLine(f, c);
return '\n';
}
c = getc(f);
if (c <= 0)
return 0;
if (c == '#') {
skipEndOfLine(f, c);
return '\n';
}
c = getc(f);
}
return c;
......@@ -73,22 +73,22 @@ getString(FILE *f, int string_end, int *c_return)
int c;
c = getc(f);
while(c > 0) {
if(c == string_end)
break;
if(c == '\\') {
c = getc(f);
if(c == '\n')
continue;
}
while (c > 0) {
if (c == string_end)
break;
if (c == '\\') {
c = getc(f);
if (c == '\n')
continue;
}
keyword[i++] = (char) c;
if(i >= MAX_KEYWORD_LENGTH)
return TOK_ERROR;
c = getc(f);
if (i >= MAX_KEYWORD_LENGTH)
return TOK_ERROR;
c = getc(f);
}
if(c <= 0)
return TOK_ERROR;
if (c <= 0)
return TOK_ERROR;
keyword[i] = '\0';
*c_return = c;
return TOK_KEYWORD;
......@@ -100,37 +100,37 @@ getToken(FILE *f, int c, int parse_assignments, int *c_return)
int i;
c = drainWhitespace(f, c);
if(c < 0)
return TOK_EOF;
if(c == '\n') {
*c_return = 0;
return TOK_EOL;
if (c < 0)
return TOK_EOF;
if (c == '\n') {
*c_return = 0;
return TOK_EOL;
}
if(parse_assignments && c == '=') {
*c_return = 0;
return TOK_EQUALS;
if (parse_assignments && c == '=') {
*c_return = 0;
return TOK_EQUALS;
}
if(c == '\'' || c == '"')
return getString(f, c, c_return);
if (c == '\'' || c == '"')
return getString(f, c, c_return);
i = 0;
while(c > 0 && c != ' ' && c != '\t' && c != '\n') {
if(c == '\\') {
c = getc(f);
if(c == '\n')
continue;
}
while (c > 0 && c != ' ' && c != '\t' && c != '\n') {
if (c == '\\') {
c = getc(f);
if (c == '\n')
continue;
}
keyword[i++] = (char) c;
if(i >= MAX_KEYWORD_LENGTH)
return TOK_ERROR;
c = getc(f);
if(parse_assignments && c == '=')
break;
if (i >= MAX_KEYWORD_LENGTH)
return TOK_ERROR;
c = getc(f);
if (parse_assignments && c == '=')
break;
}
*c_return = c<0?0:c;
*c_return = c < 0 ? 0 : c;
keyword[i] = '\0';
return TOK_KEYWORD;
}
......@@ -143,29 +143,29 @@ parseTwoTokenLine(FILE *f, char *first, char *second)
int tok;
again:
tok = getToken(f, c, 0, &c);
if(tok == TOK_EOF)
return -1;
else if(tok == TOK_EOL)
goto again;
else if(tok == TOK_KEYWORD) {
if (tok == TOK_EOF)
return -1;
else if (tok == TOK_EOL)
goto again;
else if (tok == TOK_KEYWORD) {
size_t len = strlen(keyword);
if(keyword[len - 1] == ':')
keyword[len - 1] = '\0';
strcpy(first, keyword);
if (keyword[len - 1] == ':')
keyword[len - 1] = '\0';
strcpy(first, keyword);
} else
return -2;
return -2;
tok = getToken(f, c, 0, &c);
if(tok == TOK_KEYWORD) {
strcpy(second, keyword);
if (tok == TOK_KEYWORD) {
strcpy(second, keyword);
} else
return -2;
return -2;
tok = getToken(f, c, 0, &c);
if(tok != TOK_EOL)
return -2;
if (tok != TOK_EOL)
return -2;
return 0;
}
......@@ -182,24 +182,24 @@ resolveLocale(const char *locale)
f = fopen(locale_alias, "r");
if (f != NULL) {
do {
rc = parseTwoTokenLine(f, first, second);
if(rc < -1)
do {
rc = parseTwoTokenLine(f, first, second);
if (rc < -1)
break;
if(!strcmp(first, locale)) {
if (!strcmp(first, locale)) {
resolved = strmalloc(second);
found = 1;
break;
}
} while(rc >= 0);
break;
}
} while (rc >= 0);
if (!found) {
if(resolved == NULL) {
if (resolved == NULL) {
resolved = strmalloc(locale);
}
}
}
fclose(f);
fclose(f);
} else {
perror(locale_alias);
}
......
......@@ -54,20 +54,20 @@ THE SOFTWARE.
#ifdef HAVE_WORKING_SELECT
#if defined(HAVE_SYS_SELECT_H) && defined(HAVE_SYS_TIME_SELECT)
# include <sys/select.h>
#include <sys/select.h>
#endif
#endif
#ifdef HAVE_PTY_H
# include <pty.h>
#include <pty.h>
#endif
#ifdef HAVE_STROPTS_H
# include <stropts.h>
#include <stropts.h>
#endif
#ifdef HAVE_SYS_PARAM
# include <sys/param.h>
#include <sys/param.h>
#endif
#ifdef HAVE_OPENPTY
......@@ -107,7 +107,7 @@ waitForOutput(int fd)
pfd[0].revents = 0;
rc = poll(pfd, 1, -1);
if(rc < 0)
if (rc < 0)
ret = -1;
else if (pfd[0].revents & (POLLOUT | POLLERR | POLLHUP))
ret = 1;
......@@ -149,11 +149,11 @@ waitForInput(int fd1, int fd2)
if (rc < 0) {
ret = -1;
} else {
if(pfd[0].revents & (POLLIN | POLLERR | POLLHUP))
ret |= 1;
if(pfd[1].revents & (POLLIN | POLLERR | POLLHUP))
ret |= 2;
}
if (pfd[0].revents & (POLLIN | POLLERR | POLLHUP))
ret |= 1;
if (pfd[1].revents & (POLLIN | POLLERR | POLLHUP))
ret |= 2;
}
#elif defined(HAVE_WORKING_SELECT)
fd_set fds;
......@@ -166,11 +166,11 @@ waitForInput(int fd1, int fd2)
if (rc < 0) {
ret = -1;
} else {
if(FD_ISSET(fd1, &fds))
ret |= 1;
if(FD_ISSET(fd2, &fds))
ret |= 2;
}
if (FD_ISSET(fd1, &fds))
ret |= 1;
if (FD_ISSET(fd2, &fds))
ret |= 2;
}
#else
ret = (1 | 2);
#endif
......@@ -184,18 +184,18 @@ setWindowSize(int sfd, int dfd)
#ifdef TIOCGWINSZ
int rc;
struct winsize ws;
rc = ioctl(sfd, TIOCGWINSZ, (char*)&ws);
if(rc < 0)
return -1;
rc = ioctl(dfd, TIOCSWINSZ, (char*)&ws);
if(rc < 0)
return -1;
rc = ioctl(sfd, TIOCGWINSZ, (char *) &ws);
if (rc < 0)
return -1;
rc = ioctl(dfd, TIOCSWINSZ, (char *) &ws);
if (rc < 0)
return -1;
#endif
return 0;
}
int
installHandler(int signum, void (*handler)(int))
installHandler(int signum, void (*handler) (int))
{
struct sigaction sa;
sigset_t ss;
......@@ -217,12 +217,12 @@ copyTermios(int sfd, int dfd)
int rc;
rc = tcgetattr(sfd, &tio);
if(rc < 0)
return -1;
if (rc < 0)
return -1;
rc = tcsetattr(dfd, TCSAFLUSH, &tio);
if(rc < 0)
return -1;
if (rc < 0)
return -1;
return 0;
}
......@@ -232,16 +232,16 @@ saveTermios(void)
{
int rc;
rc = tcgetattr(0, &saved_tio);
if(rc >= 0)
saved_tio_valid = 1;
if (rc >= 0)
saved_tio_valid = 1;
return rc;
}
int
restoreTermios(void)
{
if(!saved_tio_valid)
return -1;
if (!saved_tio_valid)
return -1;
return tcsetattr(0, TCSAFLUSH, &saved_tio);
}
......@@ -251,11 +251,11 @@ setRawTermios(void)
struct termios tio;
int rc;
if(!saved_tio_valid)
saveTermios();
if (!saved_tio_valid)
saveTermios();
rc = tcgetattr(0, &tio);
if(rc < 0)
return rc;
if (rc < 0)
return rc;
tio.c_lflag &= (unsigned) ~(ECHO | ICANON | ISIG);
tio.c_iflag &= (unsigned) ~(ICRNL | IXOFF | IXON | ISTRIP);
#ifdef ONLCR
......@@ -273,8 +273,8 @@ setRawTermios(void)
tio.c_cc[VTIME] = 0;
#endif
rc = tcsetattr(0, TCSAFLUSH, &tio);
if(rc < 0)
return rc;
if (rc < 0)
return rc;
return 0;
}
......@@ -284,10 +284,10 @@ my_basename(char *path)
char *p;
p = strrchr(path, '/');
if(!p)
p = path;
if (!p)
p = path;
else
p++;
p++;
return p;
}
......@@ -298,25 +298,25 @@ fix_pty_perms(char *line)
struct stat s;
rc = stat(line, &s);
if(rc < 0)
return -1;
if (rc < 0)
return -1;
if (s.st_uid != getuid() || s.st_gid != getgid()) {
rc = chown(line, getuid(), getgid());
if(rc < 0) {
fprintf(stderr,
"Warning: could not change ownership of tty -- "
"pty is insecure!\n");
return 0;
}
rc = chown(line, getuid(), getgid());
if (rc < 0) {
fprintf(stderr,
"Warning: could not change ownership of tty -- "
"pty is insecure!\n");
return 0;
}
}
if((s.st_mode & 0777) != (S_IRUSR | S_IWUSR | S_IWGRP)) {
rc = chmod(line, S_IRUSR | S_IWUSR | S_IWGRP);
if (rc < 0) {
fprintf(stderr,
"Warning: could not change permissions of tty -- "
"pty is insecure!\n");
return 0;
}
if ((s.st_mode & 0777) != (S_IRUSR | S_IWUSR | S_IWGRP)) {
rc = chmod(line, S_IRUSR | S_IWUSR | S_IWGRP);
if (rc < 0) {
fprintf(stderr,
"Warning: could not change permissions of tty -- "
"pty is insecure!\n");
return 0;
}
}
return 1;
}
......@@ -336,25 +336,25 @@ allocatePty(int *pty_return, char **line_return)
int rc;
pty = open("/dev/ptmx", O_RDWR);
if(pty < 0)
goto bsd;
if (pty < 0)
goto bsd;
rc = grantpt(pty);
if(rc < 0) {
close(pty);
goto bsd;
if (rc < 0) {
close(pty);
goto bsd;
}
rc = unlockpt(pty);
if(rc < 0) {
close(pty);
goto bsd;
if (rc < 0) {
close(pty);
goto bsd;
}
line = strmalloc(ptsname(pty));
if (!line) {
close(pty);
goto bsd;
close(pty);
goto bsd;
}
fix_pty_perms(line);
......@@ -374,8 +374,8 @@ allocatePty(int *pty_return, char **line_return)
goto bsd;
}
line = strmalloc(ttydev);
if(!line) {
close(pty);
if (!line) {
close(pty);
goto bsd;
}
......@@ -389,35 +389,35 @@ allocatePty(int *pty_return, char **line_return)
#endif /* HAVE_GRANTPT, etc */
strcpy(name, "/dev/pty??");
for(p1 = name1; *p1; p1++) {
name[8] = *p1;
for(p2 = name2; *p2; p2++) {
name[9] = *p2;
pty = open(name, O_RDWR);
if(pty >= 0)
goto found;
/* Systems derived from 4.4BSD differ in their pty names,
so ENOENT doesn't necessarily imply we're done. */
continue;
}
for (p1 = name1; *p1; p1++) {
name[8] = *p1;
for (p2 = name2; *p2; p2++) {
name[9] = *p2;
pty = open(name, O_RDWR);
if (pty >= 0)
goto found;
/* Systems derived from 4.4BSD differ in their pty names,
so ENOENT doesn't necessarily imply we're done. */
continue;
}
}
goto bail;
found:
if ((line = strmalloc(name)) != 0) {
line[5] = 't';
fix_pty_perms(line);
*pty_return = pty;
*line_return = line;
return 0;
line[5] = 't';
fix_pty_perms(line);
*pty_return = pty;
*line_return = line;
return 0;
}
bail:
if(pty >= 0)
close(pty);
if(line)
free(line);
if (pty >= 0)
close(pty);
if (line)
free(line);
return -1;
}
......@@ -438,8 +438,8 @@ openTty(char *line)
#endif
);
if(tty < 0)
goto bail;
if (tty < 0)
goto bail;
#if defined(HAVE_OPENPTY)
if (opened_tty >= 0) {
......@@ -456,31 +456,31 @@ openTty(char *line)
*
* Cygwin as of 2009/10/12 lacks this call, but has O_NOCTTY.
*/
rc = ioctl(tty, TIOCSCTTY, (char *)0);
if(rc < 0) {
goto bail;
rc = ioctl(tty, TIOCSCTTY, (char *) 0);
if (rc < 0) {
goto bail;
}
#endif
#if defined(I_PUSH) && (defined(SVR4) || defined(__SVR4))
rc = ioctl(tty, I_PUSH, "ptem");
if(rc < 0)
goto bail;
if (rc < 0)
goto bail;
rc = ioctl(tty, I_PUSH, "ldterm");
if(rc < 0)
goto bail;
if (rc < 0)
goto bail;
rc = ioctl(tty, I_PUSH, "ttcompat");
if(rc < 0)
goto bail;
if (rc < 0)
goto bail;
#endif
return tty;
bail:
if(tty >= 0)
close(tty);
if (tty >= 0)
close(tty);
return -1;
}
......@@ -495,29 +495,29 @@ droppriv(void)
rc = setuid(getuid());
if (rc >= 0) {
rc = setgid(getgid());
}
}
#elif defined(_POSIX_SAVED_IDS)
uid_t uid = getuid();
uid_t euid = geteuid();
gid_t gid = getgid();
gid_t egid = getegid();
if((uid != euid || gid != egid) && euid != 0) {
errno = ENOSYS;
if ((uid != euid || gid != egid) && euid != 0) {
errno = ENOSYS;
rc = -1;
} else {
rc = setuid(uid);
rc = setuid(uid);
if (rc >= 0)
rc = setgid(gid);
}
}
#else
uid_t uid = getuid();
uid_t euid = geteuid();
gid_t gid = getgid();
gid_t egid = getegid();
if(uid != euid || gid != egid) {
errno = ENOSYS;
if (uid != euid || gid != egid) {
errno = ENOSYS;
rc = -1;
} else {
rc = 0;
......@@ -552,4 +552,4 @@ ExitProgram(int code)
charset_leaks();
exit(code);