From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Michael Welsh Duggan Newsgroups: gmane.emacs.bugs Subject: bug#9560: Cache information during failure Date: Mon, 10 Oct 2011 00:15:04 -0400 Message-ID: <87ipnx5vp3.fsf@maru.md5i.com> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1318220167 19832 80.91.229.12 (10 Oct 2011 04:16:07 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 10 Oct 2011 04:16:07 +0000 (UTC) To: 9560@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Oct 10 06:16:02 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RD7HW-0006CV-1R for geb-bug-gnu-emacs@m.gmane.org; Mon, 10 Oct 2011 06:16:02 +0200 Original-Received: from localhost ([::1]:48683 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RD7HV-0002yo-9f for geb-bug-gnu-emacs@m.gmane.org; Mon, 10 Oct 2011 00:16:01 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:42544) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RD7HQ-0002yN-QR for bug-gnu-emacs@gnu.org; Mon, 10 Oct 2011 00:15:58 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RD7HP-0007qR-7Y for bug-gnu-emacs@gnu.org; Mon, 10 Oct 2011 00:15:56 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:53893) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RD7HN-0007q4-0Y; Mon, 10 Oct 2011 00:15:53 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1RD7HV-0005Ab-Pi; Mon, 10 Oct 2011 00:16:01 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: Resent-From: Michael Welsh Duggan Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org Resent-Date: Mon, 10 Oct 2011 04:16:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 9560 X-GNU-PR-Package: emacs,cc-mode X-GNU-PR-Keywords: Original-Received: via spool by 9560-submit@debbugs.gnu.org id=B9560.131822012619828 (code B ref 9560); Mon, 10 Oct 2011 04:16:01 +0000 Original-Received: (at 9560) by debbugs.gnu.org; 10 Oct 2011 04:15:26 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RD7Gv-00059k-IH for submit@debbugs.gnu.org; Mon, 10 Oct 2011 00:15:26 -0400 Original-Received: from md5i.com ([75.151.244.229] helo=maru.md5i.com) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RD7Gq-00059V-KG for 9560@debbugs.gnu.org; Mon, 10 Oct 2011 00:15:22 -0400 Original-Received: from md5i by maru.md5i.com with local (Exim 4.76) (envelope-from ) id 1RD7Gb-0005PN-EV for 9560@debbugs.gnu.org; Mon, 10 Oct 2011 00:15:05 -0400 User-Agent: Gnus/5.110018 (No Gnus v0.18) Emacs/24.0.50 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Mon, 10 Oct 2011 00:16:01 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:52463 Archived-At: --=-=-= Content-Type: text/plain I tried recreating the problem again, successfully. This time, I evaluated the c-state-dump function in the comments in cc-engine. Here is that state data, and the file at that point: "(setq c-state-cache '(4054 (3986 . 4048))) (setq c-state-cache-good-pos 4055) (setq c-state-nonlit-pos-cache 'nil) (setq c-state-nonlit-pos-cache-limit 3497) (setq c-state-brace-pair-desert '(3495 . 3986)) (setq c-state-point-min 1) (setq c-state-point-min-lit-type nil) (setq c-state-point-min-lit-start nil) (setq c-state-min-scan-pos 1) (setq c-state-old-cpp-beg nil) (setq c-state-old-cpp-end nil) " --=-=-= Content-Type: text/x-csrc Content-Disposition: attachment; filename=rwsiteinfo-backup.c /* ** Copyright (C) 2011 by Carnegie Mellon University. ** ** @OPENSOURCE_HEADER_START@ ** ** Use of the SILK system and related source code is subject to the terms ** of the following licenses: ** ** GNU Public License (GPL) Rights pursuant to Version 2, June 1991 ** Government Purpose License Rights (GPLR) pursuant to DFARS 252.227.7013 ** ** NO WARRANTY ** ** ANY INFORMATION, MATERIALS, SERVICES, INTELLECTUAL PROPERTY OR OTHER ** PROPERTY OR RIGHTS GRANTED OR PROVIDED BY CARNEGIE MELLON UNIVERSITY ** PURSUANT TO THIS LICENSE (HEREINAFTER THE "DELIVERABLES") ARE ON AN ** "AS-IS" BASIS. CARNEGIE MELLON UNIVERSITY MAKES NO WARRANTIES OF ANY ** KIND, EITHER EXPRESS OR IMPLIED AS TO ANY MATTER INCLUDING, BUT NOT ** LIMITED TO, WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE, ** MERCHANTABILITY, INFORMATIONAL CONTENT, NONINFRINGEMENT, OR ERROR-FREE ** OPERATION. CARNEGIE MELLON UNIVERSITY SHALL NOT BE LIABLE FOR INDIRECT, ** SPECIAL OR CONSEQUENTIAL DAMAGES, SUCH AS LOSS OF PROFITS OR INABILITY ** TO USE SAID INTELLECTUAL PROPERTY, UNDER THIS LICENSE, REGARDLESS OF ** WHETHER SUCH PARTY WAS AWARE OF THE POSSIBILITY OF SUCH DAMAGES. ** LICENSEE AGREES THAT IT WILL NOT MAKE ANY WARRANTY ON BEHALF OF ** CARNEGIE MELLON UNIVERSITY, EXPRESS OR IMPLIED, TO ANY PERSON ** CONCERNING THE APPLICATION OF OR THE RESULTS TO BE OBTAINED WITH THE ** DELIVERABLES UNDER THIS LICENSE. ** ** Licensee hereby agrees to defend, indemnify, and hold harmless Carnegie ** Mellon University, its trustees, officers, employees, and agents from ** all claims or demands made against them (and any related losses, ** expenses, or attorney's fees) arising out of, or relating to Licensee's ** and/or its sub licensees' negligent use or willful misuse of or ** negligent conduct or willful misconduct regarding the Software, ** facilities, or other rights or assistance granted by Carnegie Mellon ** University under this License, including, but not limited to, any ** claims of product liability, personal injury, death, damage to ** property, or violation of any laws or regulations. ** ** Carnegie Mellon University Software Engineering Institute authored ** documents are sponsored by the U.S. Department of Defense under ** Contract FA8721-05-C-0003. Carnegie Mellon University retains ** copyrights in all material produced under this contract. The U.S. ** Government retains a non-exclusive, royalty-free license to publish or ** reproduce these documents, or allow others to do so, for U.S. ** Government purposes only pursuant to the copyright license under the ** contract clause at 252.227.7013. ** ** @OPENSOURCE_HEADER_END@ */ /* ** Prints information about SiLK site configurations ** ** Michael Duggan ** September 2011 */ #include RCSIDENT("$Id$"); #include #include #include #include /* LOCAL DEFINES AND TYPEDEFS */ /* where to write --help output */ #define USAGE_FH stdout /* LOCAL VARIABLE DEFINITIONS */ typedef enum { RWST_CLASS, RWST_TYPE, RWST_FLOWTYPE, RWST_FLOWTYPE_ID, RWST_SENSOR, RWST_SENSOR_ID, RWST_SENSOR_DESC, RWST_DEFAULT_CLASS, RWST_DEFAULT_TYPE, RWST_MARK_DEFAULTS, RWST_CLASS_LIST, RWST_TYPE_LIST, RWST_FLOWTYPE_LIST, RWST_FLOWTYPE_ID_LIST, RWST_SENSOR_LIST, RWST_SENSOR_ID_LIST, RWST_DEFAULT_CLASS_LIST, RWST_DEFAULT_TYPE_LIST } rws_type_t; static const sk_stringmap_entry_t field_map_entries[] = { {"class", RWST_CLASS, "class name", NULL}, {"type", RWST_TYPE, "type name", NULL}, {"flowtype", RWST_FLOWTYPE, "flowtype name", NULL}, {"id-flowtype", RWST_FLOWTYPE_ID, "flowtype integer identifier", NULL}, {"sensor", RWST_SENSOR, "sensor name", NULL}, {"id-sensor", RWST_SENSOR_ID, "sensor integer identifier", NULL}, {"describe-sensor", RWST_SENSOR_DESC, "sensor description", NULL}, {"default-class", RWST_DEFAULT_CLASS, "default class name", NULL}, {"default-type", RWST_DEFAULT_TYPE, "default type name", NULL}, {"mark-defaults", RWST_MARK_DEFAULTS, " }; /* OPTIONS SETUP */ typedef enum { OPT_NO_TITLES, OPT_NO_COLUMNS, OPT_COLUMN_SEPARATOR, OPT_NO_FINAL_DELIMITER, OPT_DELIMITED, OPT_OUTPUT_PATH, OPT_PAGER } appOptionsEnum; static struct option appOptions[] = { {"no-titles", NO_ARG, 0, OPT_NO_TITLES}, {"no-columns", NO_ARG, 0, OPT_NO_COLUMNS}, {"column-separator", REQUIRED_ARG, 0, OPT_COLUMN_SEPARATOR}, {"no-final-delimiter", NO_ARG, 0, OPT_NO_FINAL_DELIMITER}, {"delimited", OPTIONAL_ARG, 0, OPT_DELIMITED}, {"output-path", REQUIRED_ARG, 0, OPT_OUTPUT_PATH}, {"pager", REQUIRED_ARG, 0, OPT_PAGER}, {0,0,0,0} /* sentinel entry */ {0,0,0,0} /* sentinel entry */ }; static const char *appHelp[] = { "Do not print column headers. Def. Print titles.", "Disable fixed-width columnar output. Def. Columnar", "Use specified character between columns. Def. '|'", "Suppress column delimiter at end of line. Def. No", "Shortcut for --no-columns --no-final-del --column-sep=CHAR", "Send output to given file path. Def. stdout", "Program to invoke to page output. Def. $SILK_PAGER or $PAGER", (char *)NULL }; /* LOCAL FUNCTION PROTOTYPES */ static void appUsageLong(void); static void appTeardown(void); static void appSetup(int argc, char **argv); static int appOptionsHandler(clientData cData, int opt_index, char *opt_arg); /* FUNCTION DEFINITIONS */ /* * appUsageLong(); * * Print complete usage information to USAGE_FH. Pass this * function to skOptionsSetUsageCallback(); skOptionsParse() will * call this funciton and then exit the program when the --help * option is given. */ static void appUsageLong(void) { #define USAGE_MSG \ ("\n" \ "\tOutputs information about a SiLK site configuration.\n") FILE *fh = USAGE_FH; int i; fprintf(fh, "%s %s", skAppName(), USAGE_MSG); fprintf(fh, "\nSWITCHES:\n"); skOptionsDefaultUsage(fh); for (i = 0; appOptions[i].name; i++ ) { fprintf(fh, "--%s %s. ", appOptions[i].name, SK_OPTION_HAS_ARG(appOptions[i])); switch (appOptions[i].val) { case OPT_FIELDS: /* Dynamically build the help */ usageFields(fh); break; default: /* Simple static help text from the appHelp array */ fprintf(fh, "%s\n", appHelp[i]); break; } } skOptionsCtxOptionsUsage(optctx, fh); } /* * appTeardown() * * Teardown all modules, close all files, and tidy up all * application state. * * This function is idempotent. */ static void appTeardown(void) { static int teardownFlag = 0; if (teardownFlag) { return; } teardownFlag = 1; #error "Anything you put in setup should now be torn down" /* for example, close sample output file */ skStreamDestroy(&out_ios); skAppUnregister(); } /* * appSetup(argc, argv); * * Perform all the setup for this application include setting up * required modules, parsing options, etc. This function should be * passed the same arguments that were passed into main(). * * Returns to the caller if all setup succeeds. If anything fails, * this function will cause the application to exit with a FAILURE * exit status. */ static void appSetup(int argc, char **argv) { SILK_FEATURES_DEFINE_STRUCT(features); int rv; /* verify same number of options and help strings */ assert((sizeof(appHelp)/sizeof(char *)) == (sizeof(appOptions)/sizeof(struct option))); /* register the application */ skAppRegister(argv[0]); skAppVerifyFeatures(&features, NULL); skOptionsSetUsageCallback(&appUsageLong); /* initialize globals */ #error "Initialize any global variables here" /* for example: set global output to NULL */ out_ios = NULL; /* register the options */ if (skOptionsRegister(appOptions, &appOptionsHandler, NULL) || sksiteOptionsRegister(SK_SITE_FLAG_CONFIG_FILE)) { skAppPrintErr("Unable to register options"); exit(EXIT_FAILURE); } #error "Do any other module setup here" /* parse the options */ arg_index = skOptionsParse(argc, argv); if (arg_index < 0) { /* options parsing should print error */ skAppUsage(); /* never returns */ } /* try to load site config file; if it fails, we will not be able * to resolve flowtype and sensor from input file names */ sksiteConfigure(0); #error "Do any options validation here" #error "If you expect filenames on command line keep this:" /* arg_index is looking at first file name to process */ if (arg_index == argc) { if (FILEIsATty(stdin)) { skAppPrintErr("No input files on command line and" " stdin is connected to a terminal"); skAppUsage(); /* never returns */ } } #error "If you do NOT expect filenames on command line, keep this:" /* check for extraneous arguments */ if (arg_index != argc) { skAppPrintErr("Too many arguments or unrecognized switch '%s'", argv[arg_index]); skAppUsage(); /* never returns */ } #error "Once all options are set, open input and output" /* for example, open a SiLK flow file as an output file */ rv = skStreamOpenSilkFlow(&out_ios, output_path, SK_IO_WRITE); if (rv) { skStreamPrintLastErr(out_ios, rv, &skAppPrintErr); skAppPrintErr("Unable to open output file. Exiting"); skStreamDestroy(&out_ios); exit(EXIT_FAILURE); } if (atexit(appTeardown) < 0) { skAppPrintErr("Unable to register appTeardown() with atexit()"); appTeardown(); exit(EXIT_FAILURE); } return; /* OK */ } /* * status = appOptionsHandler(cData, opt_index, opt_arg); * * This function is passed to skOptionsRegister(); it will be called * by skOptionsParse() for each user-specified switch that the * application has registered; it should handle the switch as * required---typically by setting global variables---and return 1 * if the switch processing failed or 0 if it succeeded. Returning * a non-zero from from the handler causes skOptionsParse() to return * a negative value. * * The clientData in 'cData' is typically ignored; 'opt_index' is * the index number that was specified as the last value for each * struct option in appOptions[]; 'opt_arg' is the user's argument * to the switch for options that have a REQUIRED_ARG or an * OPTIONAL_ARG. */ static int appOptionsHandler( clientData UNUSED(cData), int opt_index, char *opt_arg) { int rv; switch ((appOptionsEnum)opt_index) { #error "Add options handling here. Return 1 on failure." case OPT_FIRST: /* remove when real options added */ /* do something with the argument to the switch; for example, * parse as an integer */ rv = skStringParseUint32(&value, opt_arg, 0, 0); if (rv) { skAppPrintErr("Invalid %s '%s': %s", appOptions[opt_index].name, opt_arg, skStringParseStrerror(rv)); return 1; } break; case OPT_SECOND: /* remove when real options added */ /* set a flag based on this option */ flag = 1; break; } return 0; /* OK */ } /* * rwios = appNextInput(argc, argv); * * Open and return the next input file from the command line or the * standard input if no files were given on the command line. */ static skstream_t *appNextInput(int argc, char **argv) { static int initialized = 0; skstream_t *rwios = NULL; const char *fname = NULL; int rv; if (arg_index < argc) { /* get current file and prepare to get next */ fname = argv[arg_index]; ++arg_index; } else { if (initialized) { /* no more input */ return NULL; } /* input is from stdin */ fname = "stdin"; } initialized = 1; /* create rwios and open file */ rv = skStreamOpenSilkFlow(&rwios, fname, SK_IO_READ); if (rv) { skStreamPrintLastErr(rwios, rv, NULL); skStreamDestroy(&rwios); } return rwios; } int main(int argc, char **argv) { skstream_t *in_ios; int in_rv = SKSTREAM_OK; int rv = SKSTREAM_OK; appSetup(argc, argv); /* never returns on error */ #error "Loop over files on command line or read from stdin." #error "Process each file, preferably in a separate function." /* For each input, process each record */ while (NULL != (in_ios = appNextInput(argc, argv))) { while ((in_rv = skStreamReadRecord(in_ios, &rwrec)) == SKSTREAM_OK) { /* process record */ rv = skStreamWriteRecord(out_ios, &rwrec); if (SKSTREAM_OK != rv) { skStreamPrintLastErr(out_ios, rv, &skAppPrintErr); skStreamDestroy(&in_ios); goto END; } } if (SKSTREAM_ERR_EOF != in_rv) { skStreamPrintLastErr(in_ios, in_rv, &skAppPrintErr); } skStreamDestroy(&in_ios); } rv = skStreamClose(out_ios); if (SKSTREAM_OK != rv) { skStreamPrintLastErr(out_ios, rv, &skAppPrintErr); } END: return ((SKSTREAM_OK == rv) ? EXIT_SUCCESS : EXIT_FAILURE); } /* ** Local Variables: ** mode:c ** indent-tabs-mode:nil ** c-basic-offset:4 ** End: */ --=-=-= Content-Type: text/plain -- Michael Welsh Duggan (md5i@md5i.com) --=-=-=--