modeedit.c (119252) | modeedit.c (124830) |
---|---|
1/*- 2 * Copyright (c) 2000 Kelly Yancey <kbyanc@posi.net> 3 * Derived from work done by Julian Elischer <julian@tfs.com, 4 * julian@dialix.oz.au>, 1993, and Peter Dufault <dufault@hda.com>, 1994. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 13 unchanged lines hidden (view full) --- 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2000 Kelly Yancey <kbyanc@posi.net> 3 * Derived from work done by Julian Elischer <julian@tfs.com, 4 * julian@dialix.oz.au>, 1993, and Peter Dufault <dufault@hda.com>, 1994. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 13 unchanged lines hidden (view full) --- 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29#include <sys/cdefs.h> |
30__FBSDID("$FreeBSD: head/sbin/camcontrol/modeedit.c 119252 2003-08-22 01:56:17Z imp $"); | 30__FBSDID("$FreeBSD: head/sbin/camcontrol/modeedit.c 124830 2004-01-22 07:23:36Z grehan $"); |
31 32#include <sys/queue.h> 33#include <sys/types.h> 34 35#include <assert.h> 36#include <ctype.h> 37#include <err.h> 38#include <errno.h> --- 318 unchanged lines hidden (view full) --- 357 FILE *pagedb; 358 char str_pagenum[MAX_PAGENUM_LEN]; 359 char str_pagename[MAX_PAGENAME_LEN]; 360 int pagenum; 361 int depth; /* Quoting depth. */ 362 int found; 363 int lineno; 364 enum { LOCATE, PAGENAME, PAGEDEF } state; | 31 32#include <sys/queue.h> 33#include <sys/types.h> 34 35#include <assert.h> 36#include <ctype.h> 37#include <err.h> 38#include <errno.h> --- 318 unchanged lines hidden (view full) --- 357 FILE *pagedb; 358 char str_pagenum[MAX_PAGENUM_LEN]; 359 char str_pagename[MAX_PAGENAME_LEN]; 360 int pagenum; 361 int depth; /* Quoting depth. */ 362 int found; 363 int lineno; 364 enum { LOCATE, PAGENAME, PAGEDEF } state; |
365 int ch; |
|
365 char c; 366 367#define SETSTATE_LOCATE do { \ 368 str_pagenum[0] = '\0'; \ 369 str_pagename[0] = '\0'; \ 370 pagenum = -1; \ 371 state = LOCATE; \ 372} while (0) --- 19 unchanged lines hidden (view full) --- 392 returnerr(ENOENT); 393 394 SLIST_INIT(&namelist); 395 396 depth = 0; 397 lineno = 0; 398 found = 0; 399 SETSTATE_LOCATE; | 366 char c; 367 368#define SETSTATE_LOCATE do { \ 369 str_pagenum[0] = '\0'; \ 370 str_pagename[0] = '\0'; \ 371 pagenum = -1; \ 372 state = LOCATE; \ 373} while (0) --- 19 unchanged lines hidden (view full) --- 393 returnerr(ENOENT); 394 395 SLIST_INIT(&namelist); 396 397 depth = 0; 398 lineno = 0; 399 found = 0; 400 SETSTATE_LOCATE; |
400 while ((c = fgetc(pagedb)) != EOF) { | 401 while ((ch = fgetc(pagedb)) != EOF) { |
401 402 /* Keep a line count to make error messages more useful. */ 403 UPDATE_LINENO; 404 405 /* Skip over comments anywhere in the mode database. */ | 402 403 /* Keep a line count to make error messages more useful. */ 404 UPDATE_LINENO; 405 406 /* Skip over comments anywhere in the mode database. */ |
406 if (c == '#') { | 407 if (ch == '#') { |
407 do { | 408 do { |
408 c = fgetc(pagedb); 409 } while (c != '\n' && c != EOF); | 409 ch = fgetc(pagedb); 410 } while (ch != '\n' && ch != EOF); |
410 UPDATE_LINENO; 411 continue; 412 } | 411 UPDATE_LINENO; 412 continue; 413 } |
414 c = ch; |
|
413 414 /* Strip out newline characters. */ 415 if (c == '\n') 416 continue; 417 418 /* Keep track of the nesting depth for braces. */ 419 if (c == PAGEDEF_START) 420 depth++; --- 487 unchanged lines hidden --- | 415 416 /* Strip out newline characters. */ 417 if (c == '\n') 418 continue; 419 420 /* Keep track of the nesting depth for braces. */ 421 if (c == PAGEDEF_START) 422 depth++; --- 487 unchanged lines hidden --- |