/* chkcukb.c --- testing distribution of nonprinting chars Copyright (C) 2005 Free Software Foundation Inc. This file is part of GNU Emacs. GNU Emacs is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Emacs is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Emacs; see the file COPYING. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifdef HAVE_CONFIG_H #include #endif #include #ifdef HAVE_FCNTL_H #include #endif #ifdef HAVE_UNISTD_H #include #endif #ifndef O_RDONLY #define O_RDONLY 0 #endif #ifndef O_BINARY #define O_BINARY 0x8000 /* Input and output is not translated. */ #endif #ifndef EXIT_SUCCESS #define EXIT_SUCCESS 0 #endif #ifndef EXIT_FAILURE #define EXIT_FAILURE 1 #endif /* This file checks if line-endings need fixing. The reason is problem with CVS and handling of W32 style file endings. See emacs/nt/INSTALL for more information. */ char buf[300]; /* Like `read' but keeps trying until it gets SIZE bytes or reaches eof. */ int cool_read (fd, buf, size) int fd; char *buf; int size; { int num, sofar = 0; while (1) { if ((num = read (fd, buf + sofar, size - sofar)) == 0) return sofar; else if (num < 0) return num; sofar += num; } } int main (argc, argv) int argc; char **argv; { int fd; int numread; int inarow; int ii; if (argc != 2) { fprintf (stderr, "Usage: %s testfile\n", argv[0]); exit (EXIT_FAILURE); } fd = open (argv[1], O_RDONLY | O_BINARY); if (fd < 0) { perror (argv[1]); exit (EXIT_FAILURE); } numread = cool_read (fd, buf, 300); inarow = 0; for (ii = 0; ii < numread; ii++) { if (13 == buf[ii]) { inarow++; } else { inarow = 0; } if (2 == inarow) { fprintf (stderr, "ERROR: The file `%s' seems to have bad line end style.\n\ Please run 'cvs update -kb' in the emacs/nt subdirectory.\n\ For more information see emacs/nt/INSTALL.\n", argv[1]); close (fd); exit (EXIT_FAILURE); } } close (fd); return EXIT_SUCCESS; } /* chkcukb.c ends here */