From unknown Tue Aug 19 18:20:37 2025 X-Loop: owner@emacsbugs.donarmstrong.com Subject: bug#2947: 23.0.91; font-lock-mode will hang emacs on this file (both on Windows/Linux) Reply-To: Bao Haojun , 2947@debbugs.gnu.org Resent-From: Bao Haojun Resent-To: bug-submit-list@lists.donarmstrong.com Resent-CC: Emacs Bugs Resent-Date: Fri, 10 Apr 2009 05:35:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-Emacs-PR-Message: report 2947 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Received: via spool by submit@emacsbugs.donarmstrong.com id=B.123934128422276 (code B ref -1); Fri, 10 Apr 2009 05:35:03 +0000 Received: (at submit) by emacsbugs.donarmstrong.com; 10 Apr 2009 05:28:04 +0000 X-Spam-Checker-Version: SpamAssassin 3.2.5-bugs.debian.org_2005_01_02 (2008-06-10) on rzlab.ucr.edu X-Spam-Level: * X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. X-Spam-Status: No, score=2.0 required=4.0 tests=FOURLA,MDO_CABLE_TV3, WEIRD_QUOTING autolearn=no version=3.2.5-bugs.debian.org_2005_01_02 Received: from fencepost.gnu.org (fencepost.gnu.org [140.186.70.10]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id n3A5Rw2A022259 for ; Thu, 9 Apr 2009 22:28:00 -0700 Received: from mail.gnu.org ([199.232.76.166]:54509 helo=mx10.gnu.org) by fencepost.gnu.org with esmtp (Exim 4.67) (envelope-from ) id 1Ls9HR-0000Ia-QS for emacs-pretest-bug@gnu.org; Fri, 10 Apr 2009 01:27:58 -0400 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1Ls9HO-0004d2-LP for emacs-pretest-bug@gnu.org; Fri, 10 Apr 2009 01:27:57 -0400 Received: from smtp103.biz.mail.mud.yahoo.com ([68.142.200.238]:45544) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1Ls9HO-0004cu-0J for emacs-pretest-bug@gnu.org; Fri, 10 Apr 2009 01:27:54 -0400 Received: (qmail 40460 invoked from network); 10 Apr 2009 05:27:52 -0000 Received: from unknown (HELO BHJ1.borqs.com) (haojun.bao@122.200.68.238 with login) by smtp103.biz.mail.mud.yahoo.com with SMTP; 10 Apr 2009 05:27:50 -0000 X-Yahoo-SMTP: OoVJaCSswBBEswerdY_I8Ogt5424kPafFTF4mzWcwmhN X-YMail-OSG: 51R2M0gVM1mSL5HyB1OQ5UBE52fKwRVqStRzwRI.OhA4SRSG.TYpH7Rv9DJ9aceQcKlDGqvPo6ExlBjQz1jbAWzibWKxUG2e0MQXDAOA8QQUQgfGR.QpPRkzUkaf9CPL1.RxpJD..gQi4oV34MBNa3REDWRjzBvdGrW1j7ofs1ZmxAZ_SNmkITR2ze2hUMyv4p.o4xCP1wvP38lMeSDwLQ5KtBzmT._zu1M.srv5IBr4mLwpLIf.xAgR2sGbvnnnhEnsuM1WjnK33TN2CYYuo8omHo7ClmIZVup0AhjYrC3QMtt4II8AgEywxbjUPtbbQfes8NvmTERQrd_Zf7lI X-Yahoo-Newman-Property: ymail-3 From: Bao Haojun To: emacs-pretest-bug@gnu.org Date: Fri, 10 Apr 2009 13:27:51 +0800 Message-ID: <83prflkrhk.fsf@borqs.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.91 (windows-nt) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. --=-=-= The file is attached, the offending character is the last `"' character on line 117: {"get micco", MICCO_TEST, "BB>", "0x1", "}, If I run M-x font-lock-mode, emacs will hang. I have also tested on Linux emacs. In GNU Emacs 23.0.91.1 (i386-mingw-nt5.1.2600) of 2009-02-27 on SOFT-MJASON Windowing system distributor `Microsoft Corp.', version 5.1.2600 configured using `configure --with-gcc (3.4)' Important settings: value of $LC_ALL: nil value of $LC_COLLATE: nil value of $LC_CTYPE: nil value of $LC_MESSAGES: nil value of $LC_MONETARY: nil value of $LC_NUMERIC: nil value of $LC_TIME: nil value of $LANG: CHS value of $XMODIFIERS: nil locale-coding-system: cp936 default-enable-multibyte-characters: t Major mode: C++/l Minor modes in effect: auto-image-file-mode: t shell-dirtrack-mode: t mouse-wheel-mode: t file-name-shadow-mode: t blink-cursor-mode: t global-auto-composition-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t line-number-mode: t transient-mark-mode: t abbrev-mode: t Recent input: C-x C-f s r c / c l i e n g a l c j s c l i M-x M-p C-k f o n t l o m o C-e C-b C-b " C-x C-s M-x C-g M-x g l o b f o n M-x r e p o r Recent messages: Loading paren...done Loading q:/.session...done For information about GNU Emacs and the GNU system, type C-h C-a. Searching for `cli'.... Loading vc-svn...done Font-Lock mode disabled Saving file q:/src/alchemy/JSC-fork-dll/AlchemyLib/cli.cpp... Wrote q:/src/alchemy/JSC-fork-dll/AlchemyLib/cli.cpp Quit Global-Font-Lock mode disabled --=-=-= Content-Type: text/plain; charset=gb18030 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable #include "stdafx.h" #include "alchemy_internal.h" #include #include "cli.h" #define ENABLE_BHJDEBUG #include "bhjdebug.h"=20 typedef enum { FACTORY_ID =3D 0x001, GPIO_TEST =3D 0x003, REGISTER_TEST =3D 0x004, ADC_TEST =3D 0x005, REBOOT_TEST =3D 0x006, CAMERA_TEST =3D 0x007, BLUETOOTH_TEST =3D 0x008, TESTINFO =3D 0x009, ATPARSER_TEST =3D 0x00a, VIBRATOR_TEST =3D 0x00b, POWERREASON_TEST=3D0x00c, VOLTAGE_TEST =3D 0x00d, /*get real voltage by ADC */ TEMPRATURE_TEST =3D 0x00e, /*get real temprature by ADC */ CHARGETYPE_TEST =3D0x00f, GSENSOR_TEST =3D 0x010, MICCO_TEST =3D 0x011, LCDBACK_TEST =3D 0x012, KEYBACK_TEST =3D 0x013, TOUCH_POINT =3D0x014, KEY_INPUT =3D 0x015, ONLY_Key =3D 0x031, LGSENSOR_TEST =3D 0x01c, GSENSOR_INFO =3D 0x01d, =09 /* DDR test commands */ Ddr_TEST =3D 0x01f, /* LCD test commands */ LCD_TEST =3D 0x20, /* T-FLASH card detect*/ CARD_TEST =3D0x021,=20=20 /* charge status */ CHARGESTATUS_TEST =3D 0x022,=20 =20=20=20=20 /* MAT FILE Read AND write */ MAT_TEST =3D 0x023 , =09 /*audio hardware test */ AUDIO_TEST =3D 0x024, =20=20=20=20=20 =20=20=20=20 /* ADC calibration &NVM block operation related test commands*/ CALI_TEMP =3D 0x016, /*only operation on filesystem file*/ CALI_VOLT =3D 0x017, /*only operation on filesystem file*/ NVM_TEST =3D 0X018, VOLT_TEST =3D 0x019, /*read /write from filesystem to NVM block*/ TEMP_TEST =3D 0x01a, /*read /write from filesystem to NVM block*/ RF_TEST =3D 0x01b, /*read /write from filesystem to NVM block*/ TESTINFO_TEST =3D0x025,/*read /write from filesystem to NVM block*/ FACTORYID_TEST=3D0x026,/*read /write from filesystem to NVM block*/ MATFLAG_TEST=3D0x027,/*read /write from filesystem to NVM block*/ =20=20=20=20 /*touch panel test */ PANEL_TEST =3D 0x028, /*empty test */ EMPTY_TEST =3D 0x029, =20=20=20 /* bluetooth test commands */ BT_TEST =3D 0x050, BTNVM_TEST=3D 0x051, BT_INQUIRE=3D 0x052, BT_TESTMODE =3D0x053, BT_KILL=3D0x054,//kill the "/system/bin/hciattach" process after enter = into BT Test Mode /BTINQUIRE=20 /*camera test commands */ CAMERA_PREVIEW =3D 0x060, LAUNCH_CAMERA =3D 0x61, I2C_TEST =3D 0x01e, =20=20=20=20 /*CMMB test commands */ IF101_TEST=3D 0x070,=20=20=20=20 INNO_DEVICE=3D 0x071, /*enter or exit CMMB test mode*/ Signallock_TEST =3D 0x72, Sensitive_TEST =3D 0x73, IF101_SPI_TEST =3D 0x74, IF101_SET_FREQ =3D 0x75, LAUNCH_TV =3D 0x76, /* GPS test commands */=20 GPS_TEST =3D 0x80, GPS_LOCATION=3D0x81, GPS_MESSAGE=3D0x82,/*only get NEMA Message*/ GPS_LOCA_MESSAGE=3D0x83,/*only get Location Message*/ GPS_CHANGE_MODE=3D0x84,/*Change between hot mode and code mode*/ =20=20 /* SPARK */ SPARK_KEY=3D0x90,/*TEST KEY INPUT*/ /* Key Monitor */ KEY_MONITOR=3D0x91, /* Sensor Monitor */ SENSOR_MONITOR=3D0x92, /* Set/Get LPR SMS report flag */ SMS_FLAG =3D0x93, /* Set/Get LPR livetime period */ LIVETIME_PERIOD =3D 0x94, /* Set/Get EFEM feature flag */ EFEM_FLAG =3D0x95, DIAG_LAUNCH=3D0x96,=09 GET_RDNVM =3D0x9a, DIAG_EXT_INTERFACE=3D0x9b, /*to set /get element config value */ NVM_Element=3D0x9c, /*to set /get phase data : */ NVM_PHASE =3D0x9d, /*Common set/get Bit config element value*/ NVM_BITCONFIG =3D0x9e,=20 /* Version */ VERSION =3D 0x039, =20=20=20=20 /* bp only handler */ BP_ONLY =3D 0xFFFF } TC_AP_FSM_EVENT_OPCODE_T; typedef unsigned char u8; typedef unsigned short u16; typedef struct{ const char *cmdName; int opCode; const char *inputSpec; // datatype: BHIOoF, how: <>*!=20 const char *fixedInput; const char *description; =09 } testCmd_T; //< means from the fixedInput,=20 //> means from user provided input,=20 //! means arbitrary value is acceptable, so we just use 0,=20 //* means fill with a string static testCmd_T cmdMap[] =3D { {"version", VERSION, "B<", "0x12", "Read software version of the phone"}, {"get factory_id", FACTORY_ID, "B<", "0x11", "Read FactoryId of the phone"= }, {"set factory_id", FACTORY_ID, "BB!", "0x1", "Get GPIO, the u16 argument is th= e GPIO number"}, {"set gpio", GPIO_TEST, "BB>", "0x2",=20 "Set GPIO, the u16 is GPIO number, the u8 is GPIO setting\n" "the meaning of bit 7-0:\n" " level : 1, //0:low,1:High\n" " in_out: 1, //0:input, 1:output\n" " pullup: 1, //0:no pullup,1:pullup\n" " pulldown: 1, //0:no pulldown,1:pulldown\n" " tri_state: 1, //0:anit_tristate,1:tristate\n" " reserved: 3;\n" }, {"get register", REGISTER_TEST, "BI!", "0x1", "Read register value, u32= is register number. Use with caution!"}, {"set register", REGISTER_TEST, "BI>", "0x2", "Write register, first u3= 2 is register number, second is value"}, {"get adc", ADC_TEST, "B>H!", "", "Read A/D converter value, u8 is AD numb= er" }, {"reboot poweroff", REBOOT_TEST, "B<", "0x0", "reboot to poweroff mode"}, {"reboot factory", REBOOT_TEST, "B<", "0x1" "reboot to factory mode (minim= al applications will start, so boot/test is faster)"}, {"reboot normal", REBOOT_TEST, "B<", "0x2", "reboot, the `Normal' reboot"}, {"reboot flash", REBOOT_TEST, "B<", "0x3", "reboot to flash mode"}, //{"camera test", //??? {"launch camera", LAUNCH_CAMERA, "", "", "lauch camera"}, //{"bluetooth test", //??? //{"get info", TESTINFO, "B<", "0x11"}, //??? //{"set info", TESTINFO, "BB!", "0x1", "get gravity sensor value, = u8 is the gsensor number"}, {"set gsensor", GSENSOR_TEST, "BB>", "0x2", "set gsensor value, first u= 8 is the gsensor number, second is value"}, {"get micco", MICCO_TEST, "BB>", "0x1", "}, {"set micco", MICCO_TEST, "BB>", "0x2"}, {"vibrator on", VIBRATOR_TEST, "B<", "0x1"}, {"vibrator off", VIBRATOR_TEST, "B<", "0x2"}, //{"at test" //bhj: don't know what this means {"get power reason", POWERREASON_TEST, "", ""}, {"get chargetype", CHARGETYPE_TEST, "B<", "0x1"}, {"set chargetype", CHARGETYPE_TEST, "B", "0x2"}, {"get manual voltage", VOLTAGE_TEST, "B<", "0x0"}, {"get auto voltage", VOLTAGE_TEST, "B<", "0x4"}, {"get manual temperature", TEMPRATURE_TEST, "B<", "0x1"},//0x0?=20 {"get auto temperature", TEMPRATURE_TEST, "B<", "0x5"}, {"get lcdbl", LCDBACK_TEST, "B", "0x1"}, {"set lcdbl", LCDBACK_TEST, "B", "0x2"}, {"get keybl", KEYBACK_TEST, "B", "0x1"}, {"set keybl", KEYBACK_TEST, "B", "0x2"}, {"test touch", TOUCH_POINT, "", ""}, {"test keyinput",ONLY_Key,"",""}, {"get lprflag", SMS_FLAG, "B<", "0x1"}, {"set lprflag", SMS_FLAG, "B", "0x2"}, {"get lprtime", LIVETIME_PERIOD, "B<", "0x1"}, {"set lprtime", LIVETIME_PERIOD, "B", "0x2"}, {"get efemflag", EFEM_FLAG, "B<", "0x1"}, {"set efemflag", EFEM_FLAG, "B", "0x2"}, {"get cali temperature",CALI_TEMP,"B<","0x1"},//add by Jason from here {"get cali voltage",CALI_VOLT,"B<","0x1"}, {"set cali voltage",CALI_VOLT,"B",""}, {"lcd test",LCD_TEST,"B>",""}, {"card detect",CARD_TEST,"B>",""}, {"charge status",CHARGESTATUS_TEST,"B>",""}, {"audio test",AUDIO_TEST,"B>",""}, //data: 0x01: AUDIO_SD_PLAY // 0x02: AUDIO_MICRO_TEST // 0x03: AUDIO_EAR_TEST {"save rd",GET_RDNVM,"B","0x1"}, {"get diag_en",DIAG_LAUNCH,"B<","0x1"}, {"set diag_en",DIAG_LAUNCH,"B","0x2"}, {"get diag_intf",DIAG_EXT_INTERFACE,"B<","0x1"}, {"set diag_intf",DIAG_EXT_INTERFACE,"B","0x2"}, {"get element",NVM_Element,"I>B<","0x1"}, {"set element",NVM_Element,"I>BB<","0x1"}, {"set phase",NVM_PHASE,"I>B","0x2"}, {"get ap_panic_report",NVM_BITCONFIG,"I>B<","0x1"}, {"set ap_panic_report",NVM_BITCONFIG,"I>B","0x2"}, {"opcode", -1, "o>", ""}, {"reliable data", 0x97, "F>", ""}, {NULL, 0, NULL, NULL}, }; static BOOL notOptionalCode(char c) { return (c!=3D'*' && c!=3D'?'); } static BOOL isOptionalCode(char c) { return !notOptionalCode(c); } static BOOL isSingleOptional(char c) { return c=3D=3D'?'; } static BOOL isMultiOptional(char c) { return c=3D=3D'*'; } static unsigned long getLong(CString& strInput) { const char *s =3D strInput.GetBufferSetLength(strInput.GetLength()); char *firstInvalid =3D NULL; =09 long dataH =3D strtol(s, &firstInvalid, 0); strInput.ReleaseBuffer(); strInput.Delete(0, firstInvalid-s); strInput.TrimLeft(); return (unsigned long) dataH; } static int getLongCheck(CString& strInput, unsigned long& outLong)=20 { outLong =3D 0; =09 strInput.TrimLeft(); strInput.TrimRight(); if (strInput.IsEmpty()) { return -1; } int len =3D strInput.GetLength(); outLong =3D (unsigned long)getLong(strInput); if (len =3D=3D strInput.GetLength()) { return -1; } return 0; } static int getB(CString& strInput, CU8Array& dataArr) { unsigned long outLong =3D 0; if (getLongCheck(strInput, outLong) < 0) { return -1; } unsigned char data =3D (unsigned char)outLong; dataArr.Add(data); return 0; } //'H' stands for a short static int getH(CString& strInput, CU8Array& dataArr) { unsigned long outLong =3D 0; if (getLongCheck(strInput, outLong) < 0) { return -1; } unsigned short data =3D (unsigned short) outLong; //big endian or little endian? dataArr.Add(data&0xff); dataArr.Add(data>>8); return 0; } static int getI(CString& strInput, CU8Array& dataArr) { unsigned long outLong =3D 0; if (getLongCheck(strInput, outLong) < 0) { return -1; } unsigned int data =3D (unsigned int)outLong; dataArr.Add(data&0xff); //=BB=F1=C8=A1int=B5=C4=B5=CD=CE=BB=D7=D6=BD=DA dataArr.Add((data>>8) & 0xff); //=BB=F1=C8=A1int=B5=C4=B5=DA=B6=FE=B8=F6= =D7=D6=BD=DA=09 dataArr.Add((data>>16) & 0xff); //=BB=F1=C8=A1int=B5=C4=B5=DA=C8=FD=B8=F6= =D7=D6=BD=DA dataArr.Add((data>>24) &0xff); //=BB=F1=C8=A1int=B5=C4=B5=DA=CB=C4=B8=F6= =D7=D6=BD=DA return 0; } static int getF(CString& strInput, CU8Array& dataArr) { strInput.TrimLeft(); strInput.TrimRight(); FILE* fp =3D fopen(strInput, "rb"); if (fp =3D=3D NULL) { urgTrace("Error: %s open failed", (const char *)strInput); return -1; } fseek(fp, 0, SEEK_END); =09 DWORD dwLength =3D ftell(fp); rewind(fp); char *buff =3D (char *)calloc(dwLength, 1); DWORD numRead =3D 0; =09 for (;;) { numRead +=3D fread(buff+numRead, 1, dwLength, fp); if (numRead =3D=3D dwLength) break; } =09 ASSERT(numRead =3D=3D dwLength); for (DWORD i=3D0; i'; } static BOOL isFromFixed(char where) { return where =3D=3D '<'; } static BOOL isArbitrary(char where) { return where =3D=3D '!'; } static BOOL isMultiple(char where) { return where =3D=3D '*'; } static int getArg(CU8Array& dataArr, CString& strUserInput, CString& strFix= edInput, char dataType, char where) { if (dataType =3D=3D 'B') { if (isFromUser(where)) { return getB(strUserInput, dataArr); } else if (isFromFixed(where)) { return getB(strFixedInput, dataArr); } else if (isArbitrary(where)) { return getB(CString("0"), dataArr); } else if (isMultiple(where)) { //the rest of the user-input is consumed for (int k=3D0; k10) { sendTrace+=3D"..."; } dbgTrace("%s", sendTrace); int ret =3D getConnection()->UC_Do3rdCommand(opcode, dataArr, result, cmdMap[i].cmdName); printResult(result); if (ret < 0) { infoTrace("`%s`: failed!", cmdMap[i].cmdName); return -1; } else { infoTrace("`%s`: success!", cmdMap[i].cmdName); return 0; } } } if (sCommand.Find("help") =3D=3D 0) { help(); } else if (sCommand.Find("todo") =3D=3D 0) { todo(); } else if (sCommand.Find("bugs") =3D=3D 0) { bugs(); } else if (sCommand.Find("commands") =3D=3D 0) { commands(); } else { urgTrace("%s", sCommand+=3D": unknown command"); }=20 return 0; } --=-=-=-- From unknown Tue Aug 19 18:20:37 2025 X-Loop: owner@emacsbugs.donarmstrong.com Subject: bug#2947: 23.0.91; font-lock-mode will hang emacs on this file (both on Windows/Linux) Reply-To: Stefan Monnier , 2947@debbugs.gnu.org Resent-From: Stefan Monnier Resent-To: bug-submit-list@lists.donarmstrong.com Resent-CC: Emacs Bugs Resent-Date: Fri, 10 Apr 2009 17:55:05 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-Emacs-PR-Message: followup 2947 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Received: via spool by 2947-submit@emacsbugs.donarmstrong.com id=B2947.123938587224030 (code B ref 2947); Fri, 10 Apr 2009 17:55:05 +0000 Received: (at 2947) by emacsbugs.donarmstrong.com; 10 Apr 2009 17:51:12 +0000 X-Spam-Checker-Version: SpamAssassin 3.2.5-bugs.debian.org_2005_01_02 (2008-06-10) on rzlab.ucr.edu X-Spam-Level: X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. X-Spam-Status: No, score=-0.5 required=4.0 tests=FOURLA,HAS_BUG_NUMBER, MDO_CABLE_TV3,VALID_BTS_CONTROL,WEIRD_QUOTING,XIRONPORT autolearn=no version=3.2.5-bugs.debian.org_2005_01_02 Received: from ironport2-out.teksavvy.com (ironport2-out.teksavvy.com [206.248.154.182]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id n3AHoPYY023934; Fri, 10 Apr 2009 10:50:27 -0700 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AkIGACMk30lLd+7D/2dsb2JhbACBUsoOgi2BTgaFFA X-IronPort-AV: E=Sophos;i="4.40,168,1238990400"; d="scan'208";a="36879391" Received: from 75-119-238-195.dsl.teksavvy.com (HELO pastel.home) ([75.119.238.195]) by ironport2-out.teksavvy.com with ESMTP; 10 Apr 2009 13:50:19 -0400 Received: by pastel.home (Postfix, from userid 20848) id 81246E9B48; Fri, 10 Apr 2009 13:50:19 -0400 (EDT) From: Stefan Monnier To: Bao Haojun Cc: 2947@debbugs.gnu.org, Alan Mackenzie Message-ID: References: <83prflkrhk.fsf@borqs.com> Date: Fri, 10 Apr 2009 13:50:19 -0400 In-Reply-To: <83prflkrhk.fsf@borqs.com> (Bao Haojun's message of "Fri, 10 Apr 2009 13:27:51 +0800") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.92 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable reassign 2947 emacs,cc-mode thanks > The file is attached, the offending character is the last `"' > character on line 117: > {"get micco", MICCO_TEST, "BB>", "0x1", "}, > If I run M-x font-lock-mode, Emacs will hang. I have also tested on > Linux Emacs. ^^^^^ [ Emacs does not run on a bare Linux kernel. Please call the system GNU/Linux. ] IIUC the file is opened in c++-mode, right? If so, it looks like a pathological regexp (or something similar) in cc-mode. Alan, can you take a look at it? Stefan > In GNU Emacs 23.0.91.1 (i386-mingw-nt5.1.2600) > of 2009-02-27 on SOFT-MJASON > Windowing system distributor `Microsoft Corp.', version 5.1.2600 > configured using `configure --with-gcc (3.4)' > Important settings: > value of $LC_ALL: nil > value of $LC_COLLATE: nil > value of $LC_CTYPE: nil > value of $LC_MESSAGES: nil > value of $LC_MONETARY: nil > value of $LC_NUMERIC: nil > value of $LC_TIME: nil > value of $LANG: CHS > value of $XMODIFIERS: nil > locale-coding-system: cp936 > default-enable-multibyte-characters: t > Major mode: C++/l > Minor modes in effect: > auto-image-file-mode: t > shell-dirtrack-mode: t > mouse-wheel-mode: t > file-name-shadow-mode: t > blink-cursor-mode: t > global-auto-composition-mode: t > auto-composition-mode: t > auto-encryption-mode: t > auto-compression-mode: t > line-number-mode: t > transient-mark-mode: t > abbrev-mode: t > Recent input: > C-x C-f s r c / c l i e n=20 > g a l c j s =20 > c l i M-x M-p C-k f o n t l o =20 > m o C-e C-b C-b " C-x C-s M-x C-g M-x=20 > g l o b f o n M-x r e p o r =20 > > Recent messages: > Loading paren...done > Loading q:/.session...done > For information about GNU Emacs and the GNU system, type C-h C-a. > Searching for `cli'.... > Loading vc-svn...done > Font-Lock mode disabled > Saving file q:/src/alchemy/JSC-fork-dll/AlchemyLib/cli.cpp... > Wrote q:/src/alchemy/JSC-fork-dll/AlchemyLib/cli.cpp > Quit > Global-Font-Lock mode disabled > #include "stdafx.h" > #include "alchemy_internal.h" > #include > #include "cli.h" > #define ENABLE_BHJDEBUG > #include "bhjdebug.h"=20 > typedef enum > { > FACTORY_ID =3D 0x001, > GPIO_TEST =3D 0x003, > REGISTER_TEST =3D 0x004, > ADC_TEST =3D 0x005, > REBOOT_TEST =3D 0x006, > CAMERA_TEST =3D 0x007, > BLUETOOTH_TEST =3D 0x008, > TESTINFO =3D 0x009, > ATPARSER_TEST =3D 0x00a, > VIBRATOR_TEST =3D 0x00b, > POWERREASON_TEST=3D0x00c, > VOLTAGE_TEST =3D 0x00d, /*get real voltage by ADC */ > TEMPRATURE_TEST =3D 0x00e, /*get real temprature by ADC */ > CHARGETYPE_TEST =3D0x00f, > GSENSOR_TEST =3D 0x010, > MICCO_TEST =3D 0x011, > LCDBACK_TEST =3D 0x012, > KEYBACK_TEST =3D 0x013, > TOUCH_POINT =3D0x014, > KEY_INPUT =3D 0x015, > ONLY_Key =3D 0x031, > LGSENSOR_TEST =3D 0x01c, > GSENSOR_INFO =3D 0x01d, =09 > /* DDR test commands */ > Ddr_TEST =3D 0x01f, > /* LCD test commands */ > LCD_TEST =3D 0x20, > /* T-FLASH card detect*/ > CARD_TEST =3D0x021,=20=20 > /* charge status */ > CHARGESTATUS_TEST =3D 0x022,=20 =20=20=20=20 > /* MAT FILE Read AND write */ > MAT_TEST =3D 0x023 , =09 > /*audio hardware test */ > AUDIO_TEST =3D 0x024, =20=20=20=20=20 =20=20=20=20 > /* ADC calibration &NVM block operation related test commands*/ > CALI_TEMP =3D 0x016, /*only operation on filesystem file*/ > CALI_VOLT =3D 0x017, /*only operation on filesystem file*/ > NVM_TEST =3D 0X018, > VOLT_TEST =3D 0x019, /*read /write from filesystem to NVM block*/ > TEMP_TEST =3D 0x01a, /*read /write from filesystem to NVM block*/ > RF_TEST =3D 0x01b, /*read /write from filesystem to NVM block*/ > TESTINFO_TEST =3D0x025,/*read /write from filesystem to NVM block*/ > FACTORYID_TEST=3D0x026,/*read /write from filesystem to NVM block*/ > MATFLAG_TEST=3D0x027,/*read /write from filesystem to NVM block*/ =20=20=20=20 > /*touch panel test */ > PANEL_TEST =3D 0x028, > /*empty test */ > EMPTY_TEST =3D 0x029, =20=20=20 > /* bluetooth test commands */ > BT_TEST =3D 0x050, > BTNVM_TEST=3D 0x051, > BT_INQUIRE=3D 0x052, > BT_TESTMODE =3D0x053, > BT_KILL=3D0x054,//kill the "/system/bin/hciattach" process after ente= r into BT Test Mode /BTINQUIRE=20 > /*camera test commands */ > CAMERA_PREVIEW =3D 0x060, > LAUNCH_CAMERA =3D 0x61, > I2C_TEST =3D 0x01e, =20=20=20=20 > /*CMMB test commands */ > IF101_TEST=3D 0x070,=20=20=20=20 > INNO_DEVICE=3D 0x071, /*enter or exit CMMB test mode*/ > Signallock_TEST =3D 0x72, > Sensitive_TEST =3D 0x73, > IF101_SPI_TEST =3D 0x74, > IF101_SET_FREQ =3D 0x75, > LAUNCH_TV =3D 0x76, > /* GPS test commands */=20 > GPS_TEST =3D 0x80, > GPS_LOCATION=3D0x81, > GPS_MESSAGE=3D0x82,/*only get NEMA Message*/ > GPS_LOCA_MESSAGE=3D0x83,/*only get Location Message*/ > GPS_CHANGE_MODE=3D0x84,/*Change between hot mode and code mode*/ =20=20 > /* SPARK */ > SPARK_KEY=3D0x90,/*TEST KEY INPUT*/ > /* Key Monitor */ > KEY_MONITOR=3D0x91, > /* Sensor Monitor */ > SENSOR_MONITOR=3D0x92, > /* Set/Get LPR SMS report flag */ > SMS_FLAG =3D0x93, > /* Set/Get LPR livetime period */ > LIVETIME_PERIOD =3D 0x94, > /* Set/Get EFEM feature flag */ > EFEM_FLAG =3D0x95, > DIAG_LAUNCH=3D0x96,=09 > GET_RDNVM =3D0x9a, > DIAG_EXT_INTERFACE=3D0x9b, > /*to set /get element config value */ > NVM_Element=3D0x9c, > /*to set /get phase data : */ > NVM_PHASE =3D0x9d, > /*Common set/get Bit config element value*/ > NVM_BITCONFIG =3D0x9e,=20 > /* Version */ > VERSION =3D 0x039, =20=20=20=20 > /* bp only handler */ > BP_ONLY =3D 0xFFFF > } TC_AP_FSM_EVENT_OPCODE_T; > typedef unsigned char u8; > typedef unsigned short u16; > typedef struct{ > const char *cmdName; > int opCode; > const char *inputSpec; // datatype: BHIOoF, how: <>*!=20 > const char *fixedInput; > const char *description; =09 > } testCmd_T; > //< means from the fixedInput,=20 > //> means from user provided input,=20 > //! means arbitrary value is acceptable, so we just use 0,=20 > //* means fill with a string > static testCmd_T cmdMap[] =3D { > {"version", VERSION, "B<", "0x12", "Read software version of the phone"}, > {"get factory_id", FACTORY_ID, "B<", "0x11", "Read FactoryId of the phon= e"}, > {"set factory_id", FACTORY_ID, "B {"atCommand", ATPARSER_TEST, "B*", "", "Test an AT command" }, > {"get gpio", GPIO_TEST, "BB!", "0x1", "Get GPIO, the u16 argument is = the GPIO number"}, > {"set gpio", GPIO_TEST, "BB>", "0x2",=20 > "Set GPIO, the u16 is GPIO number, the u8 is GPIO setting\n" > "the meaning of bit 7-0:\n" > " level : 1, //0:low,1:High\n" > " in_out: 1, //0:input, 1:output\n" > " pullup: 1, //0:no pullup,1:pullup\n" > " pulldown: 1, //0:no pulldown,1:pulldown\n" > " tri_state: 1, //0:anit_tristate,1:tristate\n" > " reserved: 3;\n" > }, > {"get register", REGISTER_TEST, "BI!", "0x1", "Read register value, u= 32 is register number. Use with caution!"}, > {"set register", REGISTER_TEST, "BI>", "0x2", "Write register, first = u32 is register number, second is value"}, > {"get adc", ADC_TEST, "B>H!", "", "Read A/D converter value, u8 is AD nu= mber" }, > {"reboot poweroff", REBOOT_TEST, "B<", "0x0", "reboot to poweroff mode"}, > {"reboot factory", REBOOT_TEST, "B<", "0x1" "reboot to factory mode (min= imal applications will start, so boot/test is faster)"}, > {"reboot normal", REBOOT_TEST, "B<", "0x2", "reboot, the `Normal' reboot= "}, > {"reboot flash", REBOOT_TEST, "B<", "0x3", "reboot to flash mode"}, > //{"camera test", //??? > {"launch camera", LAUNCH_CAMERA, "", "", "lauch camera"}, > //{"bluetooth test", //??? > //{"get info", TESTINFO, "B<", "0x11"}, //??? > //{"set info", TESTINFO, "B {"get gsensor", GSENSOR_TEST, "BB!", "0x1", "get gravity sensor value= , u8 is the gsensor number"}, > {"set gsensor", GSENSOR_TEST, "BB>", "0x2", "set gsensor value, first= u8 is the gsensor number, second is value"}, > {"get micco", MICCO_TEST, "BB>", "0x1", "}, > {"set micco", MICCO_TEST, "BB>", "0x2"}, > {"vibrator on", VIBRATOR_TEST, "B<", "0x1"}, > {"vibrator off", VIBRATOR_TEST, "B<", "0x2"}, > //{"at test" //bhj: don't know what this means > {"get power reason", POWERREASON_TEST, "", ""}, > {"get chargetype", CHARGETYPE_TEST, "B<", "0x1"}, > {"set chargetype", CHARGETYPE_TEST, "B", "0x2"}, > {"get manual voltage", VOLTAGE_TEST, "B<", "0x0"}, > {"get auto voltage", VOLTAGE_TEST, "B<", "0x4"}, > {"get manual temperature", TEMPRATURE_TEST, "B<", "0x1"},//0x0?=20 > {"get auto temperature", TEMPRATURE_TEST, "B<", "0x5"}, > {"get lcdbl", LCDBACK_TEST, "B", "0x1"}, > {"set lcdbl", LCDBACK_TEST, "B", "0x2"}, > {"get keybl", KEYBACK_TEST, "B", "0x1"}, > {"set keybl", KEYBACK_TEST, "B", "0x2"}, > {"test touch", TOUCH_POINT, "", ""}, > {"test keyinput",ONLY_Key,"",""}, > {"get lprflag", SMS_FLAG, "B<", "0x1"}, > {"set lprflag", SMS_FLAG, "B", "0x2"}, > {"get lprtime", LIVETIME_PERIOD, "B<", "0x1"}, > {"set lprtime", LIVETIME_PERIOD, "B", "0x2"}, > {"get efemflag", EFEM_FLAG, "B<", "0x1"}, > {"set efemflag", EFEM_FLAG, "B", "0x2"}, > {"get cali temperature",CALI_TEMP,"B<","0x1"},//add by Jason from here > {"get cali voltage",CALI_VOLT,"B<","0x1"}, > {"set cali voltage",CALI_VOLT,"B {"store volt",VOLT_TEST,"B<","0x1"}, > {"load volt",VOLT_TEST,"B<","0x2"}, > {"store temp",TEMP_TEST,"B<","0x1"}, > {"load temp",TEMP_TEST,"B<","0x2"}, > {"store RF",RF_TEST,"B<","0x1"}, > {"load RF",RF_TEST,"B<","0x2"}, > {"store testinfo",TESTINFO_TEST,"B<","0x1"}, > {"load testinfo",TESTINFO_TEST,"B<","0x2"}, > {"store factoryid",FACTORYID_TEST,"B<","0x1"}, > {"load factoryid",FACTORYID_TEST,"B<","0x2"}, > {"store MATflag",MATFLAG_TEST,"B<","0x1"}, > {"load MATflag",MATFLAG_TEST,"B<","0x2"}, > {"camera preview on",CAMERA_PREVIEW,"B<","0x1"}, > {"camera preview off",CAMERA_PREVIEW,"B<","0x2"}, > {"get sensor",LGSENSOR_TEST,"B<","0x1"}, > {"i2c test",I2C_TEST,"",""}, > {"if101 test",IF101_TEST,"",""}, > {"read bt",BT_TEST,"B<","0x1"}, > {"write bt",BT_TEST,"B {"store btnvm",BTNVM_TEST,"B {"load btnvm",BTNVM_TEST,"B<","0x2"}, > {"bt inquire",BT_INQUIRE,"",""}, > {"bt testmode",BT_TESTMODE,"",""}, > {"bt kill",BT_KILL,"",""},//ljs:not find the definition > {"launch tv",LAUNCH_TV,"",""}, > {"ddr test",Ddr_TEST,"",""}, > {"gps test",GPS_TEST,"B>",""}, > {"lcd test",LCD_TEST,"B>",""}, > {"card detect",CARD_TEST,"B>",""}, > {"charge status",CHARGESTATUS_TEST,"B>",""}, > {"audio test",AUDIO_TEST,"B>",""}, > //data: 0x01: AUDIO_SD_PLAY > // 0x02: AUDIO_MICRO_TEST > // 0x03: AUDIO_EAR_TEST > {"save rd",GET_RDNVM,"B","0x1"}, > {"get diag_en",DIAG_LAUNCH,"B<","0x1"}, > {"set diag_en",DIAG_LAUNCH,"B","0x2"}, > {"get diag_intf",DIAG_EXT_INTERFACE,"B<","0x1"}, > {"set diag_intf",DIAG_EXT_INTERFACE,"B","0x2"}, > {"get element",NVM_Element,"I>B<","0x1"}, > {"set element",NVM_Element,"I>B {"get phase",NVM_PHASE,"I>B<","0x1"}, > {"set phase",NVM_PHASE,"I>B","0x2"}, > {"get ap_panic_report",NVM_BITCONFIG,"I>B<","0x1"}, > {"set ap_panic_report",NVM_BITCONFIG,"I>B","0x2"}, > {"opcode", -1, "o>", ""}, > {"reliable data", 0x97, "F>", ""}, > {NULL, 0, NULL, NULL}, > }; > static BOOL notOptionalCode(char c) > { > return (c!=3D'*' && c!=3D'?'); > } > static BOOL isOptionalCode(char c) > { > return !notOptionalCode(c); > } > static BOOL isSingleOptional(char c) > { > return c=3D=3D'?'; > } > static BOOL isMultiOptional(char c) > { > return c=3D=3D'*'; > } > static unsigned long getLong(CString& strInput) > { > const char *s =3D strInput.GetBufferSetLength(strInput.GetLength()); > char *firstInvalid =3D NULL; =09 > long dataH =3D strtol(s, &firstInvalid, 0); > strInput.ReleaseBuffer(); > strInput.Delete(0, firstInvalid-s); > strInput.TrimLeft(); > return (unsigned long) dataH; > } > static int getLongCheck(CString& strInput, unsigned long& outLong)=20 > { > outLong =3D 0; =09 > strInput.TrimLeft(); > strInput.TrimRight(); > if (strInput.IsEmpty()) { > return -1; > } > int len =3D strInput.GetLength(); > outLong =3D (unsigned long)getLong(strInput); > if (len =3D=3D strInput.GetLength()) { > return -1; > } > return 0; > } > static int getB(CString& strInput, CU8Array& dataArr) > { > unsigned long outLong =3D 0; > if (getLongCheck(strInput, outLong) < 0) { > return -1; > } > unsigned char data =3D (unsigned char)outLong; > dataArr.Add(data); > return 0; > } > //'H' stands for a short > static int getH(CString& strInput, CU8Array& dataArr) > { > unsigned long outLong =3D 0; > if (getLongCheck(strInput, outLong) < 0) { > return -1; > } > unsigned short data =3D (unsigned short) outLong; > //big endian or little endian? > dataArr.Add(data&0xff); > dataArr.Add(data>>8); > return 0; > } > static int getI(CString& strInput, CU8Array& dataArr) > { > unsigned long outLong =3D 0; > if (getLongCheck(strInput, outLong) < 0) { > return -1; > } > unsigned int data =3D (unsigned int)outLong; > dataArr.Add(data&0xff); //=E8=8E=B7=E5=8F=96int=E7=9A=84=E4=BD=8E=E4= =BD=8D=E5=AD=97=E8=8A=82 > dataArr.Add((data>>8) & 0xff); //=E8=8E=B7=E5=8F=96int=E7=9A=84=E7=AC=AC= =E4=BA=8C=E4=B8=AA=E5=AD=97=E8=8A=82=09 > dataArr.Add((data>>16) & 0xff); //=E8=8E=B7=E5=8F=96int=E7=9A=84=E7=AC= =AC=E4=B8=89=E4=B8=AA=E5=AD=97=E8=8A=82 > dataArr.Add((data>>24) &0xff); //=E8=8E=B7=E5=8F=96int=E7=9A=84=E7=AC=AC= =E5=9B=9B=E4=B8=AA=E5=AD=97=E8=8A=82 > return 0; > } > static int getF(CString& strInput, CU8Array& dataArr) > { > strInput.TrimLeft(); > strInput.TrimRight(); > FILE* fp =3D fopen(strInput, "rb"); > if (fp =3D=3D NULL) { > urgTrace("Error: %s open failed", (const char *)strInput); > return -1; > } > fseek(fp, 0, SEEK_END); =09 > DWORD dwLength =3D ftell(fp); > rewind(fp); > char *buff =3D (char *)calloc(dwLength, 1); > DWORD numRead =3D 0; =09 > for (;;) { > numRead +=3D fread(buff+numRead, 1, dwLength, fp); > if (numRead =3D=3D dwLength) > break; > } =09 > ASSERT(numRead =3D=3D dwLength); > for (DWORD i=3D0; i dataArr.Add(buff[i]); > } > free(buff); > fclose(fp); > return 0; > } > #define AppendFormat(s, fmt) do { \ > CString tmp_asfd; \ > tmp_asfd.Format fmt; \ > s+=3Dtmp_asfd; \ > } while (0) > static CString getFormat(const char *dC /* i.e., inputSpec, such as "BB*"= */) > { > CString format; > for (int i=3D0; dC[i]; i++) { > if (dC[i]=3D=3D'B' && notOptionalCode(dC[i+1])) { > continue; > } else if (dC[i]=3D=3D'B' && isMultiOptional(dC[i+1])) { > i++; > format +=3D "[string] "; > } else if (dC[i]=3D=3D'H' && isSingleOptional(dC[i+1])) { > i++; > format +=3D "[uint16] "; > } else if (dC[i]=3D=3D'I' && isSingleOptional(dC[i+1])) { > i++; > format +=3D "[uint32] "; > } else if (dC[i]=3D=3D'B' && isSingleOptional(dC[i+1])) { > i++; > format +=3D "[uint8] "; > } else if (dC[i]=3D=3D'O' && notOptionalCode(dC[i+1])) { > format +=3D "[uint32 (as opcode)] [uint8]... "; > } else if (dC[i]=3D=3D'F' && notOptionalCode(dC[i+1])) { > format +=3D "[filename] "; > } else if (dC[i]=3D=3D'o' && notOptionalCode(dC[i+1])) { > format +=3D "[uint8]... "; > } > } > if (format.IsEmpty()) { > format +=3D "no args"; > } > format +=3D "\r\n"; > return format; > } > static void commands() > { > CString helpStr("\r\nCommands:\r\n--------------------------------\r\n\r= \n"); > for (int i=3D0; cmdMap[i].cmdName!=3DNULL; i++) { > CString cmdName(cmdMap[i].cmdName); > AppendFormat(helpStr, ("%-25s : " > "opcode 0x%04x : " > "%s", cmdName,=20 > (unsigned short)cmdMap[i].opCode,=20 > getFormat(cmdMap[i].inputSpec))); > } > urgTrace("%s", helpStr); =09 > } > static void help() > { > CString helpStr("\r\nHelp:\r\n--------------------------------\r\n\r\n" > "You can type the following to get more infomation:,\r\n" > "\r\n" > " help: dislay this help\r\n" > " todo: display to-do in this tool\r\n" > " bugs: display bugs/defects known\r\n" > " commands: display a list of available commands\r\n" > "\r\n" > "When you type `commands`, the commands are displayed as `Command : Ar= gs`,\r\n" > "Leading and trailing spaces in a command is ignored,\r\n" > " for e.g., `set keybl 255` is equal to ` set keybl 255 `\r\n" > "but, space in a command is not,\r\n" > " for e.g., `get keybl` is ok, but `get keybl` is not a valid comman= d\r\n" > "for those command that want one or more u8/u16/u32 argument, \r\n" > "if none or less that required argument is supplied, a default 0 is us= ed\r\n" > " for e.g., `set register 0x33 0x44` takes 2 args\r\n" > " 0x33 is register number, 0x44 is the value, \r\n" > " i.e., register 0x33 will be set to 68 (decimal value of 0x44) \r\n" > " But, if you run `set register`, then register 0 will be set to 0\r\= n" > "And, you can use 0xf/017/15 to mean the same INT, 15."); =09=09=09 > urgTrace("%s", helpStr); > } > static void todo() > { > CString todoStr("\r\nTodo:\r\n--------------------------------\r\n\r\n" > " 1. make the interface more user-friendly\r\n" > " for e.g., get gpio should show if the i/o is pu/pd, etc.\r\n" > " 2. implement a better help system\r\n" > " 3. provide a means to clear or save the log to a file\r\n" > " 4. provide a means to save the commands executed to a file\r\n" > " 5. implement execution of commands from the saved commands file\r= \n" > " 6. fix bugs"); > urgTrace("%s", todoStr); > } > static void bugs() > { > CString bugsStr("\r\nBugs:\r\n--------------------------------\r\n\r\n" > " 1. connection is broken after you disconnect the usb cable\r\n" > " and must restart the application to reconnect\r\n" > " 2. you must connect the usb cable before you start the applicatio= n\r\n" > " 3. many other bugs, some are even undiscovered yet\r\n" > " Please help report bugs/suggestions to haojun.bao@borqs.com"); > urgTrace("%s", bugsStr); > } > static void printResult(CU8Array& result) > { > CString recvTrace("\""); > if (result.GetSize()=3D=3D0) { > return; > } > for (int k=3D0; k if (isprint(result[k])) { > recvTrace +=3D result[k]; > } else { > CString tmp; > tmp.Format("\\x%02x", result[k]); > recvTrace +=3D tmp; > } > } > recvTrace+=3D'"'; > urgTrace("%s", recvTrace); > recvTrace =3D " in hex: "; > for (k=3D0; k CString tmp; > tmp.Format("0x%02x ", result[k]); > recvTrace +=3D tmp; > } > dbgTrace("%s", recvTrace); =09=09=09=09=09=09=09=09=20=20=20 > return; > } > static BOOL isFromUser(char where) > { > return where =3D=3D '>'; > } > static BOOL isFromFixed(char where) > { > return where =3D=3D '<'; > } > static BOOL isArbitrary(char where) > { > return where =3D=3D '!'; > } > static BOOL isMultiple(char where) > { > return where =3D=3D '*'; > } > static int getArg(CU8Array& dataArr, CString& strUserInput, CString& strF= ixedInput, char dataType, char where) > { > if (dataType =3D=3D 'B') { > if (isFromUser(where)) { > return getB(strUserInput, dataArr); > } else if (isFromFixed(where)) { > return getB(strFixedInput, dataArr); > } else if (isArbitrary(where)) { > return getB(CString("0"), dataArr); > } else if (isMultiple(where)) { //the rest of the user-input is consumed > for (int k=3D0; k dataArr.Add(strUserInput[k]); > } > strUserInput =3D ""; //empty user-input > return 0; > } > } else if (dataType =3D=3D 'H') { > if (isFromUser(where)) { > return getH(strUserInput, dataArr); > } else if (isFromFixed(where)) { > return getH(strFixedInput, dataArr); > } else if (isArbitrary(where)) { > return getH(CString("0"), dataArr); > } else { > urgTrace("Error: alchemy bug detected, code is %c %c", dataType, where= ); > return -1; > } > } else if (dataType =3D=3D 'I') { > if (isFromUser(where)) { > return getI(strUserInput, dataArr); > } else if (isFromFixed(where)) { > return getI(strFixedInput, dataArr); > } else if (isArbitrary(where)) { > return getI(CString("0"), dataArr); > } else { > urgTrace("Error: alchemy bug detected, code is %c %c", dataType, where= ); > return -1; > } > } else if (dataType =3D=3D 'o') { > strUserInput.TrimLeft(); > CString savedCommand =3D strUserInput; =09=09=09=09=09 > for (int k=3D0;;k++) { //infinite loop, k is only for debugging > if (strUserInput.IsEmpty()) { > break; > } > getB(strUserInput, dataArr); > if (strUserInput =3D=3D savedCommand) { > urgTrace("invalid arguments, `%s'", savedCommand); > return -1; > } > strUserInput.TrimLeft(); > savedCommand =3D strUserInput; > } =09=09 > return 0; > } else if (dataType =3D=3D 'F') { > if (!isFromUser(where)) { > urgTrace("Error: alchemy bug detected, code is %c %c", dataType, where= ); > }=09=09=09=09 > return getF(strUserInput, dataArr); > } else { > urgTrace("Error: alchemy bug detected, code is %c %c", dataType, where); > return -1; > } > return 0; > } > int cliCarryOut(const char *sCommand) > { > return cliCarryOut(CString(sCommand)); > } > int cliCarryOut(const CString& sCommand) > { > CU8Array result; > return cliCarryOut(sCommand, result); > } > //resolve the command send by IDC_EXEC_COMMAND > int cliCarryOut(const CString& sCommandConst, CU8Array& result) > { > if (alchemyInited =3D=3D FALSE) { > urgTrace("Must call InitAlchemyLib first!\n"); > return -1; > } > //we need to change the input string, so make a copy to remove the `cons= t' > CString sCommand =3D sCommandConst; > sCommand.TrimLeft(); > sCommand.TrimRight(); =09 > for (int i=3D0; cmdMap[i].cmdName; i++) { > if (sCommand.Find(cmdMap[i].cmdName) =3D=3D 0) { > const char *inputSpec =3D cmdMap[i].inputSpec; > const char *fixedInput =3D cmdMap[i].fixedInput; > int opcode =3D cmdMap[i].opCode; // this will change if cmd is "opcod= e" =09=09=09 > //so that only args to the cmd is in sCommand > sCommand.Delete(0, strlen(cmdMap[i].cmdName)); > sCommand.TrimLeft(); =09=09=09 > CString strUserInput =3D sCommand; > CString strFixedInput =3D fixedInput? fixedInput : ""; =09=09=09 > CU8Array dataArr; //empty at first > //handle opcode first: > if (opcode < 0) { > opcode =3D getLong(strUserInput); > } =09=09=09 > for (int j=3D0; inputSpec[j]; j=3Dj+2) { > int n =3D getArg(dataArr, strUserInput, strFixedInput, inputSpec[j], = inputSpec[j+1]); > if (n < 0) { > urgTrace("Error: don't know how to parse the input string:\n %s",= (const char*)sCommandConst); > } > }=20 > if (strUserInput.GetLength()) { > urgTrace("Error: argument parse failed, `%s' is remaining in the comm= and string", strUserInput); > return -1; > } > BYTE recv[1024] =3D {0}; > int nRecv =3D 0; > CString sendTrace("send: \"opCode "); > CString tmp; > tmp.Format("0x%08x,data: ", opcode); > sendTrace+=3Dtmp; > for (int k=3D0; k CString tmp; > tmp.Format("0x%02x ", dataArr[k]); > sendTrace+=3Dtmp; > } > if (dataArr.GetSize()>10) { > sendTrace+=3D"..."; > } > dbgTrace("%s", sendTrace); > int ret =3D getConnection()->UC_Do3rdCommand(opcode, > dataArr, > result, > cmdMap[i].cmdName); > printResult(result); > if (ret < 0) { > infoTrace("`%s`: failed!", cmdMap[i].cmdName); > return -1; > } else { > infoTrace("`%s`: success!", cmdMap[i].cmdName); > return 0; > } > } > } > if (sCommand.Find("help") =3D=3D 0) { > help(); > } else if (sCommand.Find("todo") =3D=3D 0) { > todo(); > } else if (sCommand.Find("bugs") =3D=3D 0) { > bugs(); > } else if (sCommand.Find("commands") =3D=3D 0) { > commands(); > } else { > urgTrace("%s", sCommand+=3D": unknown command"); > }=20 > return 0; > } From unknown Tue Aug 19 18:20:37 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.427 (Entity 5.427) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Bao Haojun Subject: bug#2947: closed (Re: bug#2947: 23.0.91; font-lock-mode will hang emacs on this file (both on Windows/Linux)) Message-ID: References: <3nwrclakx8.fsf@fencepost.gnu.org> <83prflkrhk.fsf@borqs.com> X-Gnu-PR-Message: they-closed 2947 X-Gnu-PR-Package: emacs,cc-mode Reply-To: 2947@debbugs.gnu.org Date: Mon, 03 Oct 2011 20:20:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1317673202-12336-1" This is a multi-part message in MIME format... ------------=_1317673202-12336-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #2947: 23.0.91; font-lock-mode will hang emacs on this file (both on Window= s/Linux) which was filed against the emacs,cc-mode package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 2947@debbugs.gnu.org. --=20 2947: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D2947 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1317673202-12336-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 2947-done) by debbugs.gnu.org; 3 Oct 2011 20:19:55 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RAozS-0003Cd-SK for submit@debbugs.gnu.org; Mon, 03 Oct 2011 16:19:54 -0400 Received: from fencepost.gnu.org ([140.186.70.10]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RAozR-0003CX-EB for 2947-done@debbugs.gnu.org; Mon, 03 Oct 2011 16:19:53 -0400 Received: from rgm by fencepost.gnu.org with local (Exim 4.71) (envelope-from ) id 1RAoy3-0005NJ-M0; Mon, 03 Oct 2011 16:18:27 -0400 From: Glenn Morris To: 2947-done@debbugs.gnu.org Subject: Re: bug#2947: 23.0.91; font-lock-mode will hang emacs on this file (both on Windows/Linux) References: <83prflkrhk.fsf@borqs.com> X-Spook: Yukon computer terrorism Pine Gap CID Glock CDMA JUWTF X-Ran: BNQ+42e;zsM'$IuFUz\"plNVBnYG,u>;1{=^1dS)ecl{{z/.M/(x9wxaw~Q^ngq?~+;@`@ X-Hue: black X-Attribution: GM Date: Mon, 03 Oct 2011 16:18:27 -0400 In-Reply-To: (Stefan Monnier's message of "Fri, 10 Apr 2009 13:50:19 -0400") Message-ID: <3nwrclakx8.fsf@fencepost.gnu.org> User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Score: -6.4 (------) X-Debbugs-Envelope-To: 2947-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.4 (------) Version: 23.3 I can reproduce the problem, by opening the file in c++-mode and then doing `M-x isearch-forward get m'. (I think the original report meant line 171 rather than line 117). However, it seems to be fixed in Emacs 23.3 and up. ------------=_1317673202-12336-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by emacsbugs.donarmstrong.com; 10 Apr 2009 05:28:04 +0000 X-Spam-Checker-Version: SpamAssassin 3.2.5-bugs.debian.org_2005_01_02 (2008-06-10) on rzlab.ucr.edu X-Spam-Level: * X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. X-Spam-Status: No, score=2.0 required=4.0 tests=FOURLA,MDO_CABLE_TV3, WEIRD_QUOTING autolearn=no version=3.2.5-bugs.debian.org_2005_01_02 Received: from fencepost.gnu.org (fencepost.gnu.org [140.186.70.10]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id n3A5Rw2A022259 for ; Thu, 9 Apr 2009 22:28:00 -0700 Received: from mail.gnu.org ([199.232.76.166]:54509 helo=mx10.gnu.org) by fencepost.gnu.org with esmtp (Exim 4.67) (envelope-from ) id 1Ls9HR-0000Ia-QS for emacs-pretest-bug@gnu.org; Fri, 10 Apr 2009 01:27:58 -0400 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1Ls9HO-0004d2-LP for emacs-pretest-bug@gnu.org; Fri, 10 Apr 2009 01:27:57 -0400 Received: from smtp103.biz.mail.mud.yahoo.com ([68.142.200.238]:45544) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1Ls9HO-0004cu-0J for emacs-pretest-bug@gnu.org; Fri, 10 Apr 2009 01:27:54 -0400 Received: (qmail 40460 invoked from network); 10 Apr 2009 05:27:52 -0000 Received: from unknown (HELO BHJ1.borqs.com) (haojun.bao@122.200.68.238 with login) by smtp103.biz.mail.mud.yahoo.com with SMTP; 10 Apr 2009 05:27:50 -0000 X-Yahoo-SMTP: OoVJaCSswBBEswerdY_I8Ogt5424kPafFTF4mzWcwmhN X-YMail-OSG: 51R2M0gVM1mSL5HyB1OQ5UBE52fKwRVqStRzwRI.OhA4SRSG.TYpH7Rv9DJ9aceQcKlDGqvPo6ExlBjQz1jbAWzibWKxUG2e0MQXDAOA8QQUQgfGR.QpPRkzUkaf9CPL1.RxpJD..gQi4oV34MBNa3REDWRjzBvdGrW1j7ofs1ZmxAZ_SNmkITR2ze2hUMyv4p.o4xCP1wvP38lMeSDwLQ5KtBzmT._zu1M.srv5IBr4mLwpLIf.xAgR2sGbvnnnhEnsuM1WjnK33TN2CYYuo8omHo7ClmIZVup0AhjYrC3QMtt4II8AgEywxbjUPtbbQfes8NvmTERQrd_Zf7lI X-Yahoo-Newman-Property: ymail-3 From: Bao Haojun To: emacs-pretest-bug@gnu.org Subject: 23.0.91; font-lock-mode will hang emacs on this file (both on Windows/Linux) Date: Fri, 10 Apr 2009 13:27:51 +0800 Message-ID: <83prflkrhk.fsf@borqs.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.91 (windows-nt) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. --=-=-= The file is attached, the offending character is the last `"' character on line 117: {"get micco", MICCO_TEST, "BB>", "0x1", "}, If I run M-x font-lock-mode, emacs will hang. I have also tested on Linux emacs. In GNU Emacs 23.0.91.1 (i386-mingw-nt5.1.2600) of 2009-02-27 on SOFT-MJASON Windowing system distributor `Microsoft Corp.', version 5.1.2600 configured using `configure --with-gcc (3.4)' Important settings: value of $LC_ALL: nil value of $LC_COLLATE: nil value of $LC_CTYPE: nil value of $LC_MESSAGES: nil value of $LC_MONETARY: nil value of $LC_NUMERIC: nil value of $LC_TIME: nil value of $LANG: CHS value of $XMODIFIERS: nil locale-coding-system: cp936 default-enable-multibyte-characters: t Major mode: C++/l Minor modes in effect: auto-image-file-mode: t shell-dirtrack-mode: t mouse-wheel-mode: t file-name-shadow-mode: t blink-cursor-mode: t global-auto-composition-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t line-number-mode: t transient-mark-mode: t abbrev-mode: t Recent input: C-x C-f s r c / c l i e n g a l c j s c l i M-x M-p C-k f o n t l o m o C-e C-b C-b " C-x C-s M-x C-g M-x g l o b f o n M-x r e p o r Recent messages: Loading paren...done Loading q:/.session...done For information about GNU Emacs and the GNU system, type C-h C-a. Searching for `cli'.... Loading vc-svn...done Font-Lock mode disabled Saving file q:/src/alchemy/JSC-fork-dll/AlchemyLib/cli.cpp... Wrote q:/src/alchemy/JSC-fork-dll/AlchemyLib/cli.cpp Quit Global-Font-Lock mode disabled --=-=-= Content-Type: text/plain; charset=gb18030 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable #include "stdafx.h" #include "alchemy_internal.h" #include #include "cli.h" #define ENABLE_BHJDEBUG #include "bhjdebug.h"=20 typedef enum { FACTORY_ID =3D 0x001, GPIO_TEST =3D 0x003, REGISTER_TEST =3D 0x004, ADC_TEST =3D 0x005, REBOOT_TEST =3D 0x006, CAMERA_TEST =3D 0x007, BLUETOOTH_TEST =3D 0x008, TESTINFO =3D 0x009, ATPARSER_TEST =3D 0x00a, VIBRATOR_TEST =3D 0x00b, POWERREASON_TEST=3D0x00c, VOLTAGE_TEST =3D 0x00d, /*get real voltage by ADC */ TEMPRATURE_TEST =3D 0x00e, /*get real temprature by ADC */ CHARGETYPE_TEST =3D0x00f, GSENSOR_TEST =3D 0x010, MICCO_TEST =3D 0x011, LCDBACK_TEST =3D 0x012, KEYBACK_TEST =3D 0x013, TOUCH_POINT =3D0x014, KEY_INPUT =3D 0x015, ONLY_Key =3D 0x031, LGSENSOR_TEST =3D 0x01c, GSENSOR_INFO =3D 0x01d, =09 /* DDR test commands */ Ddr_TEST =3D 0x01f, /* LCD test commands */ LCD_TEST =3D 0x20, /* T-FLASH card detect*/ CARD_TEST =3D0x021,=20=20 /* charge status */ CHARGESTATUS_TEST =3D 0x022,=20 =20=20=20=20 /* MAT FILE Read AND write */ MAT_TEST =3D 0x023 , =09 /*audio hardware test */ AUDIO_TEST =3D 0x024, =20=20=20=20=20 =20=20=20=20 /* ADC calibration &NVM block operation related test commands*/ CALI_TEMP =3D 0x016, /*only operation on filesystem file*/ CALI_VOLT =3D 0x017, /*only operation on filesystem file*/ NVM_TEST =3D 0X018, VOLT_TEST =3D 0x019, /*read /write from filesystem to NVM block*/ TEMP_TEST =3D 0x01a, /*read /write from filesystem to NVM block*/ RF_TEST =3D 0x01b, /*read /write from filesystem to NVM block*/ TESTINFO_TEST =3D0x025,/*read /write from filesystem to NVM block*/ FACTORYID_TEST=3D0x026,/*read /write from filesystem to NVM block*/ MATFLAG_TEST=3D0x027,/*read /write from filesystem to NVM block*/ =20=20=20=20 /*touch panel test */ PANEL_TEST =3D 0x028, /*empty test */ EMPTY_TEST =3D 0x029, =20=20=20 /* bluetooth test commands */ BT_TEST =3D 0x050, BTNVM_TEST=3D 0x051, BT_INQUIRE=3D 0x052, BT_TESTMODE =3D0x053, BT_KILL=3D0x054,//kill the "/system/bin/hciattach" process after enter = into BT Test Mode /BTINQUIRE=20 /*camera test commands */ CAMERA_PREVIEW =3D 0x060, LAUNCH_CAMERA =3D 0x61, I2C_TEST =3D 0x01e, =20=20=20=20 /*CMMB test commands */ IF101_TEST=3D 0x070,=20=20=20=20 INNO_DEVICE=3D 0x071, /*enter or exit CMMB test mode*/ Signallock_TEST =3D 0x72, Sensitive_TEST =3D 0x73, IF101_SPI_TEST =3D 0x74, IF101_SET_FREQ =3D 0x75, LAUNCH_TV =3D 0x76, /* GPS test commands */=20 GPS_TEST =3D 0x80, GPS_LOCATION=3D0x81, GPS_MESSAGE=3D0x82,/*only get NEMA Message*/ GPS_LOCA_MESSAGE=3D0x83,/*only get Location Message*/ GPS_CHANGE_MODE=3D0x84,/*Change between hot mode and code mode*/ =20=20 /* SPARK */ SPARK_KEY=3D0x90,/*TEST KEY INPUT*/ /* Key Monitor */ KEY_MONITOR=3D0x91, /* Sensor Monitor */ SENSOR_MONITOR=3D0x92, /* Set/Get LPR SMS report flag */ SMS_FLAG =3D0x93, /* Set/Get LPR livetime period */ LIVETIME_PERIOD =3D 0x94, /* Set/Get EFEM feature flag */ EFEM_FLAG =3D0x95, DIAG_LAUNCH=3D0x96,=09 GET_RDNVM =3D0x9a, DIAG_EXT_INTERFACE=3D0x9b, /*to set /get element config value */ NVM_Element=3D0x9c, /*to set /get phase data : */ NVM_PHASE =3D0x9d, /*Common set/get Bit config element value*/ NVM_BITCONFIG =3D0x9e,=20 /* Version */ VERSION =3D 0x039, =20=20=20=20 /* bp only handler */ BP_ONLY =3D 0xFFFF } TC_AP_FSM_EVENT_OPCODE_T; typedef unsigned char u8; typedef unsigned short u16; typedef struct{ const char *cmdName; int opCode; const char *inputSpec; // datatype: BHIOoF, how: <>*!=20 const char *fixedInput; const char *description; =09 } testCmd_T; //< means from the fixedInput,=20 //> means from user provided input,=20 //! means arbitrary value is acceptable, so we just use 0,=20 //* means fill with a string static testCmd_T cmdMap[] =3D { {"version", VERSION, "B<", "0x12", "Read software version of the phone"}, {"get factory_id", FACTORY_ID, "B<", "0x11", "Read FactoryId of the phone"= }, {"set factory_id", FACTORY_ID, "BB!", "0x1", "Get GPIO, the u16 argument is th= e GPIO number"}, {"set gpio", GPIO_TEST, "BB>", "0x2",=20 "Set GPIO, the u16 is GPIO number, the u8 is GPIO setting\n" "the meaning of bit 7-0:\n" " level : 1, //0:low,1:High\n" " in_out: 1, //0:input, 1:output\n" " pullup: 1, //0:no pullup,1:pullup\n" " pulldown: 1, //0:no pulldown,1:pulldown\n" " tri_state: 1, //0:anit_tristate,1:tristate\n" " reserved: 3;\n" }, {"get register", REGISTER_TEST, "BI!", "0x1", "Read register value, u32= is register number. Use with caution!"}, {"set register", REGISTER_TEST, "BI>", "0x2", "Write register, first u3= 2 is register number, second is value"}, {"get adc", ADC_TEST, "B>H!", "", "Read A/D converter value, u8 is AD numb= er" }, {"reboot poweroff", REBOOT_TEST, "B<", "0x0", "reboot to poweroff mode"}, {"reboot factory", REBOOT_TEST, "B<", "0x1" "reboot to factory mode (minim= al applications will start, so boot/test is faster)"}, {"reboot normal", REBOOT_TEST, "B<", "0x2", "reboot, the `Normal' reboot"}, {"reboot flash", REBOOT_TEST, "B<", "0x3", "reboot to flash mode"}, //{"camera test", //??? {"launch camera", LAUNCH_CAMERA, "", "", "lauch camera"}, //{"bluetooth test", //??? //{"get info", TESTINFO, "B<", "0x11"}, //??? //{"set info", TESTINFO, "BB!", "0x1", "get gravity sensor value, = u8 is the gsensor number"}, {"set gsensor", GSENSOR_TEST, "BB>", "0x2", "set gsensor value, first u= 8 is the gsensor number, second is value"}, {"get micco", MICCO_TEST, "BB>", "0x1", "}, {"set micco", MICCO_TEST, "BB>", "0x2"}, {"vibrator on", VIBRATOR_TEST, "B<", "0x1"}, {"vibrator off", VIBRATOR_TEST, "B<", "0x2"}, //{"at test" //bhj: don't know what this means {"get power reason", POWERREASON_TEST, "", ""}, {"get chargetype", CHARGETYPE_TEST, "B<", "0x1"}, {"set chargetype", CHARGETYPE_TEST, "B", "0x2"}, {"get manual voltage", VOLTAGE_TEST, "B<", "0x0"}, {"get auto voltage", VOLTAGE_TEST, "B<", "0x4"}, {"get manual temperature", TEMPRATURE_TEST, "B<", "0x1"},//0x0?=20 {"get auto temperature", TEMPRATURE_TEST, "B<", "0x5"}, {"get lcdbl", LCDBACK_TEST, "B", "0x1"}, {"set lcdbl", LCDBACK_TEST, "B", "0x2"}, {"get keybl", KEYBACK_TEST, "B", "0x1"}, {"set keybl", KEYBACK_TEST, "B", "0x2"}, {"test touch", TOUCH_POINT, "", ""}, {"test keyinput",ONLY_Key,"",""}, {"get lprflag", SMS_FLAG, "B<", "0x1"}, {"set lprflag", SMS_FLAG, "B", "0x2"}, {"get lprtime", LIVETIME_PERIOD, "B<", "0x1"}, {"set lprtime", LIVETIME_PERIOD, "B", "0x2"}, {"get efemflag", EFEM_FLAG, "B<", "0x1"}, {"set efemflag", EFEM_FLAG, "B", "0x2"}, {"get cali temperature",CALI_TEMP,"B<","0x1"},//add by Jason from here {"get cali voltage",CALI_VOLT,"B<","0x1"}, {"set cali voltage",CALI_VOLT,"B",""}, {"lcd test",LCD_TEST,"B>",""}, {"card detect",CARD_TEST,"B>",""}, {"charge status",CHARGESTATUS_TEST,"B>",""}, {"audio test",AUDIO_TEST,"B>",""}, //data: 0x01: AUDIO_SD_PLAY // 0x02: AUDIO_MICRO_TEST // 0x03: AUDIO_EAR_TEST {"save rd",GET_RDNVM,"B","0x1"}, {"get diag_en",DIAG_LAUNCH,"B<","0x1"}, {"set diag_en",DIAG_LAUNCH,"B","0x2"}, {"get diag_intf",DIAG_EXT_INTERFACE,"B<","0x1"}, {"set diag_intf",DIAG_EXT_INTERFACE,"B","0x2"}, {"get element",NVM_Element,"I>B<","0x1"}, {"set element",NVM_Element,"I>BB<","0x1"}, {"set phase",NVM_PHASE,"I>B","0x2"}, {"get ap_panic_report",NVM_BITCONFIG,"I>B<","0x1"}, {"set ap_panic_report",NVM_BITCONFIG,"I>B","0x2"}, {"opcode", -1, "o>", ""}, {"reliable data", 0x97, "F>", ""}, {NULL, 0, NULL, NULL}, }; static BOOL notOptionalCode(char c) { return (c!=3D'*' && c!=3D'?'); } static BOOL isOptionalCode(char c) { return !notOptionalCode(c); } static BOOL isSingleOptional(char c) { return c=3D=3D'?'; } static BOOL isMultiOptional(char c) { return c=3D=3D'*'; } static unsigned long getLong(CString& strInput) { const char *s =3D strInput.GetBufferSetLength(strInput.GetLength()); char *firstInvalid =3D NULL; =09 long dataH =3D strtol(s, &firstInvalid, 0); strInput.ReleaseBuffer(); strInput.Delete(0, firstInvalid-s); strInput.TrimLeft(); return (unsigned long) dataH; } static int getLongCheck(CString& strInput, unsigned long& outLong)=20 { outLong =3D 0; =09 strInput.TrimLeft(); strInput.TrimRight(); if (strInput.IsEmpty()) { return -1; } int len =3D strInput.GetLength(); outLong =3D (unsigned long)getLong(strInput); if (len =3D=3D strInput.GetLength()) { return -1; } return 0; } static int getB(CString& strInput, CU8Array& dataArr) { unsigned long outLong =3D 0; if (getLongCheck(strInput, outLong) < 0) { return -1; } unsigned char data =3D (unsigned char)outLong; dataArr.Add(data); return 0; } //'H' stands for a short static int getH(CString& strInput, CU8Array& dataArr) { unsigned long outLong =3D 0; if (getLongCheck(strInput, outLong) < 0) { return -1; } unsigned short data =3D (unsigned short) outLong; //big endian or little endian? dataArr.Add(data&0xff); dataArr.Add(data>>8); return 0; } static int getI(CString& strInput, CU8Array& dataArr) { unsigned long outLong =3D 0; if (getLongCheck(strInput, outLong) < 0) { return -1; } unsigned int data =3D (unsigned int)outLong; dataArr.Add(data&0xff); //=BB=F1=C8=A1int=B5=C4=B5=CD=CE=BB=D7=D6=BD=DA dataArr.Add((data>>8) & 0xff); //=BB=F1=C8=A1int=B5=C4=B5=DA=B6=FE=B8=F6= =D7=D6=BD=DA=09 dataArr.Add((data>>16) & 0xff); //=BB=F1=C8=A1int=B5=C4=B5=DA=C8=FD=B8=F6= =D7=D6=BD=DA dataArr.Add((data>>24) &0xff); //=BB=F1=C8=A1int=B5=C4=B5=DA=CB=C4=B8=F6= =D7=D6=BD=DA return 0; } static int getF(CString& strInput, CU8Array& dataArr) { strInput.TrimLeft(); strInput.TrimRight(); FILE* fp =3D fopen(strInput, "rb"); if (fp =3D=3D NULL) { urgTrace("Error: %s open failed", (const char *)strInput); return -1; } fseek(fp, 0, SEEK_END); =09 DWORD dwLength =3D ftell(fp); rewind(fp); char *buff =3D (char *)calloc(dwLength, 1); DWORD numRead =3D 0; =09 for (;;) { numRead +=3D fread(buff+numRead, 1, dwLength, fp); if (numRead =3D=3D dwLength) break; } =09 ASSERT(numRead =3D=3D dwLength); for (DWORD i=3D0; i'; } static BOOL isFromFixed(char where) { return where =3D=3D '<'; } static BOOL isArbitrary(char where) { return where =3D=3D '!'; } static BOOL isMultiple(char where) { return where =3D=3D '*'; } static int getArg(CU8Array& dataArr, CString& strUserInput, CString& strFix= edInput, char dataType, char where) { if (dataType =3D=3D 'B') { if (isFromUser(where)) { return getB(strUserInput, dataArr); } else if (isFromFixed(where)) { return getB(strFixedInput, dataArr); } else if (isArbitrary(where)) { return getB(CString("0"), dataArr); } else if (isMultiple(where)) { //the rest of the user-input is consumed for (int k=3D0; k10) { sendTrace+=3D"..."; } dbgTrace("%s", sendTrace); int ret =3D getConnection()->UC_Do3rdCommand(opcode, dataArr, result, cmdMap[i].cmdName); printResult(result); if (ret < 0) { infoTrace("`%s`: failed!", cmdMap[i].cmdName); return -1; } else { infoTrace("`%s`: success!", cmdMap[i].cmdName); return 0; } } } if (sCommand.Find("help") =3D=3D 0) { help(); } else if (sCommand.Find("todo") =3D=3D 0) { todo(); } else if (sCommand.Find("bugs") =3D=3D 0) { bugs(); } else if (sCommand.Find("commands") =3D=3D 0) { commands(); } else { urgTrace("%s", sCommand+=3D": unknown command"); }=20 return 0; } --=-=-=-- ------------=_1317673202-12336-1--