summaryrefslogtreecommitdiffstats
path: root/text-utils/more.c
diff options
context:
space:
mode:
authorJames Youngman2008-05-14 10:51:40 +0200
committerKarel Zak2008-06-16 11:54:28 +0200
commit115e6f00b81a3a30d91294250419ef006d102258 (patch)
treec60f74443fa459995a841c02231f65f0ce73ef4a /text-utils/more.c
parentbuild-sys: release++ (v2.14) (diff)
downloadkernel-qcow2-util-linux-115e6f00b81a3a30d91294250419ef006d102258.tar.gz
kernel-qcow2-util-linux-115e6f00b81a3a30d91294250419ef006d102258.tar.xz
kernel-qcow2-util-linux-115e6f00b81a3a30d91294250419ef006d102258.zip
more: minor fixes to magic()
Read the magic bytes into signed chars instead of vanilla chars in order to ensure consistent results even on systems whose char type has no sign. Eliminate spurious parentheses in return statements. Correct grammatical errors in comments. Signed-off-by: James Youngman <jay@gnu.org>
Diffstat (limited to 'text-utils/more.c')
-rw-r--r--text-utils/more.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/text-utils/more.c b/text-utils/more.c
index dc38ff2a7..f251b279f 100644
--- a/text-utils/more.c
+++ b/text-utils/more.c
@@ -531,18 +531,18 @@ checkf (fs, clearfirst)
/*
* magic --
* check for file magic numbers. This code would best be shared with
- * the file(1) program or, perhaps, more should not try and be so smart?
+ * the file(1) program or, perhaps, more should not try to be so smart.
*/
static int
magic(f, fs)
FILE *f;
char *fs;
{
- char twobytes[2];
+ signed char twobytes[2];
/* don't try to look ahead if the input is unseekable */
if (fseek(f, 0L, SEEK_SET))
- return(0);
+ return 0;
if (fread(twobytes, 2, 1, f) == 1) {
switch(twobytes[0] + (twobytes[1]<<8)) {
@@ -555,11 +555,11 @@ magic(f, fs)
case 0x457f: /* simple ELF detection */
printf(_("\n******** %s: Not a text file ********\n\n"), fs);
(void)fclose(f);
- return(1);
+ return 1;
}
}
(void)fseek(f, 0L, SEEK_SET); /* rewind() not necessary */
- return(0);
+ return 0;
}
/*