From ef4da17646a80d564dc8a74088a4b8e30ca56e6b Mon Sep 17 00:00:00 2001 From: Martin Vogel Date: Mon, 18 Feb 2002 23:13:03 +0000 Subject: [PATCH] 2002-02-19 00:05 UTC+0100 Martin Vogel --- harbour/ChangeLog | 14 + harbour/contrib/libct/Makefile | 3 + harbour/contrib/libct/charonly.c | 29 + harbour/contrib/libct/charrepl.c | 14 + harbour/contrib/libct/cterror.ch | 942 ++++++++++++++------------- harbour/contrib/libct/ctflist.txt | 10 +- harbour/contrib/libct/ftoc.c | 169 +++++ harbour/contrib/libct/makefile.bc | 15 + harbour/contrib/libct/makefile.vc | 6 + harbour/contrib/libct/misc1.c | 146 +++++ harbour/contrib/libct/readme.txt | 10 + harbour/contrib/libct/remove.c | 2 +- harbour/contrib/libct/tab.c | 593 +++++++++++++++++ harbour/contrib/libct/tests/Makefile | 1 + harbour/contrib/libct/tests/tab.prg | 167 +++++ 15 files changed, 1647 insertions(+), 474 deletions(-) create mode 100644 harbour/contrib/libct/ftoc.c create mode 100644 harbour/contrib/libct/misc1.c create mode 100644 harbour/contrib/libct/tab.c create mode 100644 harbour/contrib/libct/tests/tab.prg diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 1b3a9fb1c5..6b17d79648 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -7,6 +7,20 @@ For example: 2002-12-01 23:12 UTC+0100 Foo Bar */ + * minor fix borrowed from [x]Harbour + Many thanks to Ron + + It fixes this kind of code: + + #xcommand INIT[] ; + =>; + + contrib/libct/tab.c + + function Main() + + INIT["test"] + + return nil 2002-02-18 23:41 UTC-0300 Luiz Rafael Culik * utils/hbmake/hbmake.prg diff --git a/harbour/contrib/libct/Makefile b/harbour/contrib/libct/Makefile index 635575619a..c74afac58a 100644 --- a/harbour/contrib/libct/Makefile +++ b/harbour/contrib/libct/Makefile @@ -34,9 +34,11 @@ C_SOURCES = \ ctcrypt.c \ files.c \ finan.c \ + ftoc.c \ justify.c \ keyset.c \ math.c \ + misc1.c \ num1.c \ numat.c \ pad.c \ @@ -49,6 +51,7 @@ C_SOURCES = \ remove.c \ replace.c \ strswap.c \ + tab.c \ token1.c \ token2.c \ trig.c \ diff --git a/harbour/contrib/libct/charonly.c b/harbour/contrib/libct/charonly.c index 17cb9f3b16..0678b5ae1c 100644 --- a/harbour/contrib/libct/charonly.c +++ b/harbour/contrib/libct/charonly.c @@ -83,6 +83,35 @@ static void do_charonly (int iSwitch) int iShift, iBool; char *pcSub, *pc; + /* check for zero-length strings */ + switch (iSwitch) + { + case DO_CHARONLY_CHARONLY: + case DO_CHARONLY_WORDONLY: + { + if ((sStrLen == 0) || (sOnlySetLen == 0)) + { + hb_retc (""); + return; + } + }; break; + + case DO_CHARONLY_CHARREM: + case DO_CHARONLY_WORDREM: + { + if (sStrLen == 0) + { + hb_retc (""); + return; + } + if (sOnlySetLen == 0) + { + hb_retclen (pcString, sStrLen); + return; + } + }; break; + } + if ((iSwitch == DO_CHARONLY_WORDONLY) || (iSwitch == DO_CHARONLY_WORDREM)) { iShift = 2; diff --git a/harbour/contrib/libct/charrepl.c b/harbour/contrib/libct/charrepl.c index 1d70973525..04d54e30b3 100644 --- a/harbour/contrib/libct/charrepl.c +++ b/harbour/contrib/libct/charrepl.c @@ -145,6 +145,20 @@ HB_FUNC (CHARREPL) char *pcRet; size_t sIndex; + /* if sStrLen == 0, we can return immediately */ + if (sStrLen == 0) + { + if (iNoRet) + { + hb_retl (0); + } + else + { + hb_retc (""); + } + return; + } + if (ISLOG (4)) { iMode = hb_parl (4); diff --git a/harbour/contrib/libct/cterror.ch b/harbour/contrib/libct/cterror.ch index 285cf44ff9..a3cd3ff4b5 100644 --- a/harbour/contrib/libct/cterror.ch +++ b/harbour/contrib/libct/cterror.ch @@ -61,55 +61,55 @@ #define CT_ERROR_MATHLIB_RANGEH 199 #define CT_ERROR_GENERAL_RANGEL 1000 /* general functions */ -#define CT_ERROR_GENERAL_RANGEH 1099 +#define CT_ERROR_GENERAL_RANGEH 1199 -#define CT_ERROR_WINDOW_RANGEL 1110 /* windowing functions */ -#define CT_ERROR_WINDOW_RANGEH 1399 +#define CT_ERROR_WINDOW_RANGEL 1200 /* windowing functions */ +#define CT_ERROR_WINDOW_RANGEH 1599 -#define CT_ERROR_EXTDRV_RANGEL 1410 /* extended driver functions */ -#define CT_ERROR_EXTDRV_RANGEH 1999 +#define CT_ERROR_EXTDRV_RANGEL 1600 /* extended driver functions */ +#define CT_ERROR_EXTDRV_RANGEH 2399 -#define CT_ERROR_SERIAL_RANGEL 2110 /* serial communication functions */ -#define CT_ERROR_SERIAL_RANGEH 2599 +#define CT_ERROR_SERIAL_RANGEL 2400 /* serial communication functions */ +#define CT_ERROR_SERIAL_RANGEH 3099 -#define CT_ERROR_STRING_RANGEL 3110 /* string functions */ -#define CT_ERROR_STRING_RANGEH 4099 +#define CT_ERROR_STRING_RANGEL 3100 /* string functions */ +#define CT_ERROR_STRING_RANGEH 4499 -#define CT_ERROR_NUMBIT_RANGEL 4110 /* number and bit manipulation functions */ -#define CT_ERROR_NUMBIT_RANGEH 4399 +#define CT_ERROR_NUMBIT_RANGEL 4500 /* number and bit manipulation functions */ +#define CT_ERROR_NUMBIT_RANGEH 4999 -#define CT_ERROR_VIDEO_RANGEL 4410 /* video functions */ -#define CT_ERROR_VIDEO_RANGEH 5099 +#define CT_ERROR_VIDEO_RANGEL 5000 /* video functions */ +#define CT_ERROR_VIDEO_RANGEH 5699 -#define CT_ERROR_DISC_RANGEL 5110 /* disc functions */ -#define CT_ERROR_DISC_RANGEH 5699 +#define CT_ERROR_DISC_RANGEL 5700 /* disc functions */ +#define CT_ERROR_DISC_RANGEH 6399 -#define CT_ERROR_PRINT_RANGEL 5710 /* printer functions */ -#define CT_ERROR_PRINT_RANGEH 5899 +#define CT_ERROR_PRINT_RANGEL 6400 /* printer functions */ +#define CT_ERROR_PRINT_RANGEH 6699 -#define CT_ERROR_DATE_RANGEL 5910 /* date & time functions */ -#define CT_ERROR_DATE_RANGEH 6199 +#define CT_ERROR_DATE_RANGEL 6700 /* date & time functions */ +#define CT_ERROR_DATE_RANGEH 7099 -#define CT_ERROR_DBF_RANGEL 6210 /* DBF functions */ -#define CT_ERROR_DBF_RANGEH 6299 +#define CT_ERROR_DBF_RANGEL 7100 /* DBF functions */ +#define CT_ERROR_DBF_RANGEH 7299 -#define CT_ERROR_SWITCH_RANGEL 6310 /* switch functions */ -#define CT_ERROR_SWITCH_RANGEH 6799 +#define CT_ERROR_SWITCH_RANGEL 7300 /* switch functions */ +#define CT_ERROR_SWITCH_RANGEH 7799 -#define CT_ERROR_SYSINF_RANGEL 6810 /* system info functions */ -#define CT_ERROR_SYSINF_RANGEH 7099 +#define CT_ERROR_SYSINF_RANGEL 7800 /* system info functions */ +#define CT_ERROR_SYSINF_RANGEH 8099 -#define CT_ERROR_MISC_RANGEL 7110 /* misc. functions */ -#define CT_ERROR_MISC_RANGEH 7399 +#define CT_ERROR_MISC_RANGEL 8100 /* misc. functions */ +#define CT_ERROR_MISC_RANGEH 8399 -#define CT_ERROR_MATH_RANGEL 7410 /* math functions */ -#define CT_ERROR_MATH_RANGEH 7699 +#define CT_ERROR_MATH_RANGEL 8400 /* math functions */ +#define CT_ERROR_MATH_RANGEH 8699 -#define CT_ERROR_PEEK_RANGEL 7810 /* peek & poke functions */ -#define CT_ERROR_PEEK_RANGEH 7899 +#define CT_ERROR_PEEK_RANGEL 8800 /* peek & poke functions */ +#define CT_ERROR_PEEK_RANGEH 8899 -#define CT_ERROR_GETREAD_RANGEL 7910 /* get & read functions */ -#define CT_ERROR_GETREAD_RANGEH 8099 +#define CT_ERROR_GETREAD_RANGEL 8900 /* get & read functions */ +#define CT_ERROR_GETREAD_RANGEH 9099 /* C math lib error sub codes */ #define CT_ERROR_MATHLIB 100 /* unknown math lib error */ @@ -148,121 +148,121 @@ #define CT_ERROR_CSETARGERR 1032 /* windowing functions */ -#define CT_ERROR_WACLOSE 1112 -#define CT_ERROR_WBOARD 1122 -#define CT_ERROR_WBOX 1132 -#define CT_ERROR_WCENTER 1142 -#define CT_ERROR_WCLOSE 1152 -#define CT_ERROR_WCOL 1162 -#define CT_ERROR_WFCOL 1172 -#define CT_ERROR_WFLASTCOL 1192 -#define CT_ERROR_WFORMAT 1202 -#define CT_ERROR_WFROW 1212 -#define CT_ERROR_WLASTCOL 1222 -#define CT_ERROR_WLASTROW 1232 -#define CT_ERROR_WNUM 1242 -#define CT_ERROR_WMODE 1252 -#define CT_ERROR_WMOVE 1262 -#define CT_ERROR_WOPEN 1272 -#define CT_ERROR_WROW 1282 -#define CT_ERROR_WSELECT 1292 -#define CT_ERROR_WSETMOVE 1304 -#define CT_ERROR_WSETSHADOW 1312 -#define CT_ERROR_WSTEP 1322 +#define CT_ERROR_WACLOSE 1212 +#define CT_ERROR_WBOARD 1222 +#define CT_ERROR_WBOX 1232 +#define CT_ERROR_WCENTER 1242 +#define CT_ERROR_WCLOSE 1252 +#define CT_ERROR_WCOL 1262 +#define CT_ERROR_WFCOL 1272 +#define CT_ERROR_WFLASTCOL 1292 +#define CT_ERROR_WFORMAT 1302 +#define CT_ERROR_WFROW 1312 +#define CT_ERROR_WLASTCOL 1322 +#define CT_ERROR_WLASTROW 1332 +#define CT_ERROR_WNUM 1342 +#define CT_ERROR_WMODE 1352 +#define CT_ERROR_WMOVE 1362 +#define CT_ERROR_WOPEN 1372 +#define CT_ERROR_WROW 1382 +#define CT_ERROR_WSELECT 1392 +#define CT_ERROR_WSETMOVE 1404 +#define CT_ERROR_WSETSHADOW 1412 +#define CT_ERROR_WSTEP 1422 /* extended driver */ -#define CT_ERROR_CGA40 1414 -#define CT_ERROR_CGA80 1424 -#define CT_ERROR_DSETKBIOS 1434 -#define CT_ERROR_DSETNOLINE 1444 -#define CT_ERROR_DSETQFILE 1454 -#define CT_ERROR_DSETTYPE 1462 -#define CT_ERROR_DSETWINDOW 1474 -#define CT_ERROR_EGA43 1484 -#define CT_ERROR_FIRSTCOL 1492 -#define CT_ERROR_FIRSTROW 1502 -#define CT_ERROR_GETBOXGROW 1512 -#define CT_ERROR_GETCURSOR 1522 -#define CT_ERROR_GETKXLAT 1532 -#define CT_ERROR_GETKXTAB 1541 -#define CT_ERROR_GETLINES 1552 -#define CT_ERROR_GETMODE 1561 -#define CT_ERROR_GETPAGE 1572 -#define CT_ERROR_GETPBIOS 1582 -#define CT_ERROR_GETPXLAT 1591 -#define CT_ERROR_GETSCRMODE 1602 -#define CT_ERROR_GETTAB 1611 -#define CT_ERROR_INKEYTRAP 1622 -#define CT_ERROR_INPUTMODE 1632 -#define CT_ERROR_KEYREAD 1641 -#define CT_ERROR_KEYSEND 1654 -#define CT_ERROR_MAXCOL 1662 -#define CT_ERROR_MAXPAGE 1672 -#define CT_ERROR_MAXROW 1682 -#define CT_ERROR_MONOCHROME 1694 -#define CT_ERROR_PAGECOPY 1704 -#define CT_ERROR_PRINTERROR 1712 -#define CT_ERROR_SETBELL 1721 -#define CT_ERROR_SETBOXGROW 1731 -#define CT_ERROR_SETCURSOR 1742 -#define CT_ERROR_SETKXLAT 1754 -#define CT_ERROR_SETKXTAB 1764 -#define CT_ERROR_SETLINES 1771 -#define CT_ERROR_SETMAXCOL 1784 -#define CT_ERROR_SETMAXROW 1794 -#define CT_ERROR_SETPAGE 1804 -#define CT_ERROR_SETPBIOS 1814 -#define CT_ERROR_SETPXLAT 1824 -#define CT_ERROR_SETQNAME 1834 -#define CT_ERROR_SETSCRMODE 1844 -#define CT_ERROR_SETTAB 1854 -#define CT_ERROR_TRAPANYKEY 1861 -#define CT_ERROR_TRAPINPUT 1871 -#define CT_ERROR_TRAPSHIFT 1881 -#define CT_ERROR_VGA28 1894 -#define CT_ERROR_VGA50 1904 +#define CT_ERROR_CGA40 1614 +#define CT_ERROR_CGA80 1624 +#define CT_ERROR_DSETKBIOS 1634 +#define CT_ERROR_DSETNOLINE 1644 +#define CT_ERROR_DSETQFILE 1654 +#define CT_ERROR_DSETTYPE 1662 +#define CT_ERROR_DSETWINDOW 1674 +#define CT_ERROR_EGA43 1684 +#define CT_ERROR_FIRSTCOL 1692 +#define CT_ERROR_FIRSTROW 1702 +#define CT_ERROR_GETBOXGROW 1712 +#define CT_ERROR_GETCURSOR 1722 +#define CT_ERROR_GETKXLAT 1732 +#define CT_ERROR_GETKXTAB 1741 +#define CT_ERROR_GETLINES 1752 +#define CT_ERROR_GETMODE 1761 +#define CT_ERROR_GETPAGE 1772 +#define CT_ERROR_GETPBIOS 1782 +#define CT_ERROR_GETPXLAT 1791 +#define CT_ERROR_GETSCRMODE 1802 +#define CT_ERROR_GETTAB 1811 +#define CT_ERROR_INKEYTRAP 1822 +#define CT_ERROR_INPUTMODE 1832 +#define CT_ERROR_KEYREAD 1841 +#define CT_ERROR_KEYSEND 1854 +#define CT_ERROR_MAXCOL 1862 +#define CT_ERROR_MAXPAGE 1872 +#define CT_ERROR_MAXROW 1882 +#define CT_ERROR_MONOCHROME 1894 +#define CT_ERROR_PAGECOPY 1904 +#define CT_ERROR_PRINTERROR 1912 +#define CT_ERROR_SETBELL 1921 +#define CT_ERROR_SETBOXGROW 1931 +#define CT_ERROR_SETCURSOR 1942 +#define CT_ERROR_SETKXLAT 1954 +#define CT_ERROR_SETKXTAB 1964 +#define CT_ERROR_SETLINES 1971 +#define CT_ERROR_SETMAXCOL 1984 +#define CT_ERROR_SETMAXROW 1994 +#define CT_ERROR_SETPAGE 2004 +#define CT_ERROR_SETPBIOS 2014 +#define CT_ERROR_SETPXLAT 2024 +#define CT_ERROR_SETQNAME 2034 +#define CT_ERROR_SETSCRMODE 2044 +#define CT_ERROR_SETTAB 2054 +#define CT_ERROR_TRAPANYKEY 2061 +#define CT_ERROR_TRAPINPUT 2071 +#define CT_ERROR_TRAPSHIFT 2081 +#define CT_ERROR_VGA28 2094 +#define CT_ERROR_VGA50 2104 /* serial communication */ -#define CT_ERROR_COM_BREAK 2114 -#define CT_ERROR_COM_CLOSE 2124 -#define CT_ERROR_COM_COUNT 2132 -#define CT_ERROR_COM_CRC 2142 -#define CT_ERROR_COM_CTS 2154 -#define CT_ERROR_COM_DCD 2164 -#define CT_ERROR_COM_DOSCON 2171 -#define CT_ERROR_COM_DSR 2184 -#define CT_ERROR_COM_DTR 2194 -#define CT_ERROR_COM_ERRCHR 2204 -#define CT_ERROR_COM_EVENT 2212 -#define CT_ERROR_COM_FLUSH 2224 -#define CT_ERROR_COM_GETIO 2232 -#define CT_ERROR_COM_GETIRQ 2242 -#define CT_ERROR_COM_HARD 2254 -#define CT_ERROR_COM_INIT 2264 -#define CT_ERROR_COM_KEY 2274 -#define CT_ERROR_COM_LSR 2282 -#define CT_ERROR_COM_MCR 2292 -#define CT_ERROR_COM_MSR 2302 -#define CT_ERROR_COM_NUM 2312 -#define CT_ERROR_COM_OPEN 2324 -#define CT_ERROR_COM_READ 2331 -#define CT_ERROR_COM_REMOTE 2344 -#define CT_ERROR_COM_RING 2354 -#define CT_ERROR_COM_RTS 2364 -#define CT_ERROR_COM_SCOUNT 2372 -#define CT_ERROR_COM_SEND 2382 -#define CT_ERROR_COM_SETIO 2394 -#define CT_ERROR_COM_SETIRQ 2404 -#define CT_ERROR_COM_SFLUSH 2414 -#define CT_ERROR_COM_SKEY 2424 -#define CT_ERROR_COM_SMODE 2432 -#define CT_ERROR_COM_SOFT 2444 -#define CT_ERROR_COM_SOFT_R 2454 -#define CT_ERROR_COM_SOFT_S 2464 -#define CT_ERROR_XMOBLOCK 2471 -#define CT_ERROR_XMOCHECK 2482 -#define CT_ERROR_ZEROINSERT 2491 -#define CT_ERROR_ZEROREMOVE 2501 +#define CT_ERROR_COM_BREAK 2414 +#define CT_ERROR_COM_CLOSE 2424 +#define CT_ERROR_COM_COUNT 2432 +#define CT_ERROR_COM_CRC 2442 +#define CT_ERROR_COM_CTS 2454 +#define CT_ERROR_COM_DCD 2464 +#define CT_ERROR_COM_DOSCON 2471 +#define CT_ERROR_COM_DSR 2484 +#define CT_ERROR_COM_DTR 2494 +#define CT_ERROR_COM_ERRCHR 2504 +#define CT_ERROR_COM_EVENT 2512 +#define CT_ERROR_COM_FLUSH 2524 +#define CT_ERROR_COM_GETIO 2532 +#define CT_ERROR_COM_GETIRQ 2542 +#define CT_ERROR_COM_HARD 2554 +#define CT_ERROR_COM_INIT 2564 +#define CT_ERROR_COM_KEY 2574 +#define CT_ERROR_COM_LSR 2582 +#define CT_ERROR_COM_MCR 2592 +#define CT_ERROR_COM_MSR 2602 +#define CT_ERROR_COM_NUM 2612 +#define CT_ERROR_COM_OPEN 2624 +#define CT_ERROR_COM_READ 2631 +#define CT_ERROR_COM_REMOTE 2644 +#define CT_ERROR_COM_RING 2654 +#define CT_ERROR_COM_RTS 2664 +#define CT_ERROR_COM_SCOUNT 2672 +#define CT_ERROR_COM_SEND 2682 +#define CT_ERROR_COM_SETIO 2694 +#define CT_ERROR_COM_SETIRQ 2704 +#define CT_ERROR_COM_SFLUSH 2714 +#define CT_ERROR_COM_SKEY 2724 +#define CT_ERROR_COM_SMODE 2732 +#define CT_ERROR_COM_SOFT 2744 +#define CT_ERROR_COM_SOFT_R 2754 +#define CT_ERROR_COM_SOFT_S 2764 +#define CT_ERROR_XMOBLOCK 2771 +#define CT_ERROR_XMOCHECK 2782 +#define CT_ERROR_ZEROINSERT 2791 +#define CT_ERROR_ZEROREMOVE 2801 /* string functions */ #define CT_ERROR_ADDASCII 3111 @@ -364,352 +364,358 @@ #define CT_ERROR_WORDTOCHAR 4071 /* number and bit manipulation */ -#define CT_ERROR_BITTOC 4111 -#define CT_ERROR_CELSIUS 4123 -#define CT_ERROR_CLEARBIT 4132 -#define CT_ERROR_CTOBIT 4142 -#define CT_ERROR_CTOF 4153 -#define CT_ERROR_CTON 4162 -#define CT_ERROR_EXPONENT 4172 -#define CT_ERROR_FAHRENHEIT 4183 -#define CT_ERROR_FTOC 4191 -#define CT_ERROR_INFINITY 4203 -#define CT_ERROR_INTNEG 4212 -#define CT_ERROR_INTPOS 4222 -#define CT_ERROR_ISBIT 4234 -#define CT_ERROR_LTON 4242 -#define CT_ERROR_MANTISSA 4253 -#define CT_ERROR_NTOC 4261 -#define CT_ERROR_NUMAND 4272 -#define CT_ERROR_NUMCOUNT 4282 -#define CT_ERROR_NUMHIGH 4292 -#define CT_ERROR_NUMLOW 4302 -#define CT_ERROR_NUMMIRR 4312 -#define CT_ERROR_NUMNOT 4322 -#define CT_ERROR_NUMOR 4332 -#define CT_ERROR_NUMROL 4342 -#define CT_ERROR_NUMXOR 4352 -#define CT_ERROR_RAND 4363 -#define CT_ERROR_RANDOM 4372 -#define CT_ERROR_SETBIT 4382 +#define CT_ERROR_BITTOC 4511 +#define CT_ERROR_CELSIUS 4523 +#define CT_ERROR_CLEARBIT 4532 +#define CT_ERROR_CTOBIT 4542 +#define CT_ERROR_CTOF 4553 +#define CT_ERROR_CTON 4562 +#define CT_ERROR_EXPONENT 4572 +#define CT_ERROR_FAHRENHEIT 4583 +#define CT_ERROR_FTOC 4591 +#define CT_ERROR_INFINITY 4603 +#define CT_ERROR_INTNEG 4612 +#define CT_ERROR_INTPOS 4622 +#define CT_ERROR_ISBIT 4634 +#define CT_ERROR_LTON 4642 +#define CT_ERROR_MANTISSA 4653 +#define CT_ERROR_NTOC 4661 +#define CT_ERROR_NUMAND 4672 +#define CT_ERROR_NUMCOUNT 4682 +#define CT_ERROR_NUMHIGH 4692 +#define CT_ERROR_NUMLOW 4702 +#define CT_ERROR_NUMMIRR 4712 +#define CT_ERROR_NUMNOT 4722 +#define CT_ERROR_NUMOR 4732 +#define CT_ERROR_NUMROL 4742 +#define CT_ERROR_NUMXOR 4752 +#define CT_ERROR_RAND 4763 +#define CT_ERROR_RANDOM 4772 +#define CT_ERROR_SETBIT 4782 +#define CT_ERROR_NUMANDX 4792 +#define CT_ERROR_NUMMIRRX 4802 +#define CT_ERROR_NUMNOTX 4812 +#define CT_ERROR_NUMORX 4822 +#define CT_ERROR_NUMROLX 4832 +#define CT_ERROR_NUMXORX 4842 /* video functions */ -#define CT_ERROR_CHARPIX 4412 -#define CT_ERROR_CHARWIN 4421 -#define CT_ERROR_CLEAREOL 4431 -#define CT_ERROR_CLEARSLOW 4441 -#define CT_ERROR_CLEARWIN 4451 -#define CT_ERROR_CLEOL 4461 -#define CT_ERROR_CLWIN 4471 -#define CT_ERROR_COLORREPL 4481 -#define CT_ERROR_COLORTON 4492 -#define CT_ERROR_COLORWIN 4501 -#define CT_ERROR_EGAPALETTE 4514 -#define CT_ERROR_ENHANCED 4521 -#define CT_ERROR_FILESCREEN 4532 -#define CT_ERROR_FONTLOAD 4542 -#define CT_ERROR_FONTRESET 4554 -#define CT_ERROR_FONTROTATE 4561 -#define CT_ERROR_FONTSELECT 4572 -#define CT_ERROR_GETCLEARA 4582 -#define CT_ERROR_GETCLEARB 4592 -#define CT_ERROR_GETFONT 4601 -#define CT_ERROR_GETSCRSTR 4611 -#define CT_ERROR_GETVGAPAL 4622 -#define CT_ERROR_INVERTATTR 4632 -#define CT_ERROR_INVERTWIN 4641 -#define CT_ERROR_ISCGA 4654 -#define CT_ERROR_ISEGA 4664 -#define CT_ERROR_ISHERCULES 4674 -#define CT_ERROR_ISMCGA 4684 -#define CT_ERROR_ISMONO 4694 -#define CT_ERROR_ISPGA 4704 -#define CT_ERROR_ISVGA 4714 -#define CT_ERROR_MAXFONT 4722 -#define CT_ERROR_MONISWITCH 4734 -#define CT_ERROR_NTOCOLOR 4741 -#define CT_ERROR_NUMCOL 4752 -#define CT_ERROR_RESTCURSOR 4761 -#define CT_ERROR_SAVECURSOR 4772 -#define CT_ERROR_SAYDOWN 4781 -#define CT_ERROR_SAYMOVEIN 4791 -#define CT_ERROR_SAYSCREEN 4801 -#define CT_ERROR_SAYSPREAD 4811 -#define CT_ERROR_SCREENATTR 4822 -#define CT_ERROR_SCREENFILE 4832 -#define CT_ERROR_SCREENMARK 4844 -#define CT_ERROR_SCREENMIX 4851 -#define CT_ERROR_SCREENSIZE 4862 -#define CT_ERROR_SCREENSTR 4871 -#define CT_ERROR_SETCLEARA 4881 -#define CT_ERROR_SETCLEARB 4891 -#define CT_ERROR_SETFONT 4902 -#define CT_ERROR_SETRC 4911 -#define CT_ERROR_SETSCRSTR 4924 -#define CT_ERROR_STANDARD 4931 -#define CT_ERROR_STRSCREEN 4941 -#define CT_ERROR_UNSELECTED 4951 -#define CT_ERROR_UNTEXTWIN 4961 -#define CT_ERROR_VGAPALETTE 4974 -#define CT_ERROR_VIDEOINIT 4989 -#define CT_ERROR_VIDEOSETUP 4992 -#define CT_ERROR_VIDEOTYPE 5002 +#define CT_ERROR_CHARPIX 5012 +#define CT_ERROR_CHARWIN 5021 +#define CT_ERROR_CLEAREOL 5031 +#define CT_ERROR_CLEARSLOW 5041 +#define CT_ERROR_CLEARWIN 5051 +#define CT_ERROR_CLEOL 5061 +#define CT_ERROR_CLWIN 5071 +#define CT_ERROR_COLORREPL 5081 +#define CT_ERROR_COLORTON 5092 +#define CT_ERROR_COLORWIN 5101 +#define CT_ERROR_EGAPALETTE 5114 +#define CT_ERROR_ENHANCED 5121 +#define CT_ERROR_FILESCREEN 5132 +#define CT_ERROR_FONTLOAD 5142 +#define CT_ERROR_FONTRESET 5154 +#define CT_ERROR_FONTROTATE 5161 +#define CT_ERROR_FONTSELECT 5172 +#define CT_ERROR_GETCLEARA 5182 +#define CT_ERROR_GETCLEARB 5192 +#define CT_ERROR_GETFONT 5201 +#define CT_ERROR_GETSCRSTR 5211 +#define CT_ERROR_GETVGAPAL 5222 +#define CT_ERROR_INVERTATTR 5232 +#define CT_ERROR_INVERTWIN 5241 +#define CT_ERROR_ISCGA 5254 +#define CT_ERROR_ISEGA 5264 +#define CT_ERROR_ISHERCULES 5274 +#define CT_ERROR_ISMCGA 5284 +#define CT_ERROR_ISMONO 5294 +#define CT_ERROR_ISPGA 5304 +#define CT_ERROR_ISVGA 5314 +#define CT_ERROR_MAXFONT 5322 +#define CT_ERROR_MONISWITCH 5334 +#define CT_ERROR_NTOCOLOR 5341 +#define CT_ERROR_NUMCOL 5352 +#define CT_ERROR_RESTCURSOR 5361 +#define CT_ERROR_SAVECURSOR 5372 +#define CT_ERROR_SAYDOWN 5381 +#define CT_ERROR_SAYMOVEIN 5491 +#define CT_ERROR_SAYSCREEN 5401 +#define CT_ERROR_SAYSPREAD 5411 +#define CT_ERROR_SCREENATTR 5422 +#define CT_ERROR_SCREENFILE 5432 +#define CT_ERROR_SCREENMARK 5444 +#define CT_ERROR_SCREENMIX 5451 +#define CT_ERROR_SCREENSIZE 5462 +#define CT_ERROR_SCREENSTR 5471 +#define CT_ERROR_SETCLEARA 5481 +#define CT_ERROR_SETCLEARB 5491 +#define CT_ERROR_SETFONT 5502 +#define CT_ERROR_SETRC 5511 +#define CT_ERROR_SETSCRSTR 5524 +#define CT_ERROR_STANDARD 5531 +#define CT_ERROR_STRSCREEN 5541 +#define CT_ERROR_UNSELECTED 5551 +#define CT_ERROR_UNTEXTWIN 5561 +#define CT_ERROR_VGAPALETTE 5574 +#define CT_ERROR_VIDEOINIT 5589 +#define CT_ERROR_VIDEOSETUP 5592 +#define CT_ERROR_VIDEOTYPE 5602 /* disc functions */ -#define CT_ERROR_DELETEFILE 5112 -#define CT_ERROR_DIRCHANGE 5122 -#define CT_ERROR_DIRMAKE 5132 -#define CT_ERROR_DIRNAME 5141 -#define CT_ERROR_DIRREMOVE 5152 -#define CT_ERROR_DISKCHANGE 5164 -#define CT_ERROR_DISKCHECK 5172 -#define CT_ERROR_DISKFORMAT 5182 -#define CT_ERROR_DISKFREE 5192 -#define CT_ERROR_DISKNAME 5201 -#define CT_ERROR_DISKREADY 5214 -#define CT_ERROR_DISKREADYW 5224 -#define CT_ERROR_DISKSPEED 5232 -#define CT_ERROR_DISKSTAT 5242 -#define CT_ERROR_DISKTOTAL 5252 -#define CT_ERROR_DISKTYPE 5262 -#define CT_ERROR_DRIVETYPE 5272 -#define CT_ERROR_FILEAPPEND 5282 -#define CT_ERROR_FILEATTR 5292 -#define CT_ERROR_FILECCLOSE 5304 -#define CT_ERROR_FILECCONT 5312 -#define CT_ERROR_FILECDATI 5324 -#define CT_ERROR_FILECHECK 5332 -#define CT_ERROR_FILECOPEN 5344 -#define CT_ERROR_FILECOPY 5352 -#define CT_ERROR_FILEDATE 5365 -#define CT_ERROR_FILEDELETE 5374 -#define CT_ERROR_FILEMOVE 5382 -#define CT_ERROR_FILESEEK 5391 -#define CT_ERROR_FILESIZE 5402 -#define CT_ERROR_FILESTR 5411 -#define CT_ERROR_FILETIME 5421 -#define CT_ERROR_FILEVALID 5434 -#define CT_ERROR_FLOPPYTYPE 5442 -#define CT_ERROR_GETSHARE 5452 -#define CT_ERROR_NUMDISKF 5462 -#define CT_ERROR_NUMDISKH 5472 -#define CT_ERROR_NUMDISKL 5482 -#define CT_ERROR_RENAMEFILE 5492 -#define CT_ERROR_RESTFSEEK 5501 -#define CT_ERROR_SAVEFSEEK 5511 -#define CT_ERROR_SETFATTR 5522 -#define CT_ERROR_SETFCREATE 5532 -#define CT_ERROR_SETFDATI 5544 -#define CT_ERROR_SETSHARE 5554 -#define CT_ERROR_STRFILE 5562 -#define CT_ERROR_TEMPFILE 5571 -#define CT_ERROR_TRUENAME 5581 -#define CT_ERROR_VOLSERIAL 5592 -#define CT_ERROR_VOLUME 5604 +#define CT_ERROR_DELETEFILE 5712 +#define CT_ERROR_DIRCHANGE 5722 +#define CT_ERROR_DIRMAKE 5732 +#define CT_ERROR_DIRNAME 5741 +#define CT_ERROR_DIRREMOVE 5752 +#define CT_ERROR_DISKCHANGE 5764 +#define CT_ERROR_DISKCHECK 5772 +#define CT_ERROR_DISKFORMAT 5782 +#define CT_ERROR_DISKFREE 5792 +#define CT_ERROR_DISKNAME 5801 +#define CT_ERROR_DISKREADY 5814 +#define CT_ERROR_DISKREADYW 5824 +#define CT_ERROR_DISKSPEED 5832 +#define CT_ERROR_DISKSTAT 5842 +#define CT_ERROR_DISKTOTAL 5852 +#define CT_ERROR_DISKTYPE 5862 +#define CT_ERROR_DRIVETYPE 5872 +#define CT_ERROR_FILEAPPEND 5882 +#define CT_ERROR_FILEATTR 5892 +#define CT_ERROR_FILECCLOSE 5904 +#define CT_ERROR_FILECCONT 5912 +#define CT_ERROR_FILECDATI 5924 +#define CT_ERROR_FILECHECK 5932 +#define CT_ERROR_FILECOPEN 5944 +#define CT_ERROR_FILECOPY 5952 +#define CT_ERROR_FILEDATE 5965 +#define CT_ERROR_FILEDELETE 5974 +#define CT_ERROR_FILEMOVE 5982 +#define CT_ERROR_FILESEEK 5991 +#define CT_ERROR_FILESIZE 6002 +#define CT_ERROR_FILESTR 6011 +#define CT_ERROR_FILETIME 6021 +#define CT_ERROR_FILEVALID 6034 +#define CT_ERROR_FLOPPYTYPE 6042 +#define CT_ERROR_GETSHARE 6052 +#define CT_ERROR_NUMDISKF 6062 +#define CT_ERROR_NUMDISKH 6072 +#define CT_ERROR_NUMDISKL 6082 +#define CT_ERROR_RENAMEFILE 6092 +#define CT_ERROR_RESTFSEEK 6101 +#define CT_ERROR_SAVEFSEEK 6111 +#define CT_ERROR_SETFATTR 6122 +#define CT_ERROR_SETFCREATE 6132 +#define CT_ERROR_SETFDATI 6144 +#define CT_ERROR_SETSHARE 6154 +#define CT_ERROR_STRFILE 6162 +#define CT_ERROR_TEMPFILE 6171 +#define CT_ERROR_TRUENAME 6181 +#define CT_ERROR_VOLSERIAL 6192 +#define CT_ERROR_VOLUME 6204 /* printer functions */ -#define CT_ERROR_NUMPRINTER 5712 -#define CT_ERROR_PRINTFILE 5724 -#define CT_ERROR_PRINTINIT 5732 -#define CT_ERROR_PRINTREADY 5744 -#define CT_ERROR_PRINTSCR 5751 -#define CT_ERROR_PRINTSCRX 5764 -#define CT_ERROR_PRINTSEND 5772 -#define CT_ERROR_PRINTSTAT 5782 -#define CT_ERROR_SPOOLACTIV 5794 -#define CT_ERROR_SPOOLADD 5804 -#define CT_ERROR_SPOOLCOUNT 5812 -#define CT_ERROR_SPOOLDEL 5824 -#define CT_ERROR_SPOOLENTRY 5831 -#define CT_ERROR_SPOOLFLUSH 5844 -#define CT_ERROR_TOF 5854 +#define CT_ERROR_NUMPRINTER 6412 +#define CT_ERROR_PRINTFILE 6424 +#define CT_ERROR_PRINTINIT 6432 +#define CT_ERROR_PRINTREADY 6444 +#define CT_ERROR_PRINTSCR 6451 +#define CT_ERROR_PRINTSCRX 6464 +#define CT_ERROR_PRINTSEND 6472 +#define CT_ERROR_PRINTSTAT 6482 +#define CT_ERROR_SPOOLACTIV 6494 +#define CT_ERROR_SPOOLADD 6504 +#define CT_ERROR_SPOOLCOUNT 6512 +#define CT_ERROR_SPOOLDEL 6524 +#define CT_ERROR_SPOOLENTRY 6531 +#define CT_ERROR_SPOOLFLUSH 6544 +#define CT_ERROR_TOF 6554 /* date & time functions */ -#define CT_ERROR_ADDMONTH 5915 -#define CT_ERROR_BOM 5925 -#define CT_ERROR_BOQ 5935 -#define CT_ERROR_BOY 5945 -#define CT_ERROR_CTODOW 5952 -#define CT_ERROR_CTOMONTH 5962 -#define CT_ERROR_DMY 5971 -#define CT_ERROR_DOY 5982 -#define CT_ERROR_EOM 5995 -#define CT_ERROR_EOQ 6005 -#define CT_ERROR_EOY 6015 -#define CT_ERROR_ISLEAP 6024 -#define CT_ERROR_LASTDAYOM 6032 -#define CT_ERROR_MDY 6041 -#define CT_ERROR_NTOCDOW 6051 -#define CT_ERROR_NTOCMONTH 6061 -#define CT_ERROR_QUARTER 6072 -#define CT_ERROR_SECTOTIME 6081 -#define CT_ERROR_SETDATE 6094 -#define CT_ERROR_SETTIME 6104 -#define CT_ERROR_SHOWTIME 6111 -#define CT_ERROR_STOD 6125 -#define CT_ERROR_TIMETOSEC 6132 -#define CT_ERROR_TIMEVALID 6144 -#define CT_ERROR_WAITPERIOD 6154 -#define CT_ERROR_WEEK 6162 -#define CT_ERROR_WOM 6172 +#define CT_ERROR_ADDMONTH 6715 +#define CT_ERROR_BOM 6725 +#define CT_ERROR_BOQ 6735 +#define CT_ERROR_BOY 6745 +#define CT_ERROR_CTODOW 6752 +#define CT_ERROR_CTOMONTH 6762 +#define CT_ERROR_DMY 6771 +#define CT_ERROR_DOY 6782 +#define CT_ERROR_EOM 6795 +#define CT_ERROR_EOQ 6805 +#define CT_ERROR_EOY 6815 +#define CT_ERROR_ISLEAP 6824 +#define CT_ERROR_LASTDAYOM 6832 +#define CT_ERROR_MDY 6841 +#define CT_ERROR_NTOCDOW 6851 +#define CT_ERROR_NTOCMONTH 6861 +#define CT_ERROR_QUARTER 6872 +#define CT_ERROR_SECTOTIME 6881 +#define CT_ERROR_SETDATE 6894 +#define CT_ERROR_SETTIME 6904 +#define CT_ERROR_SHOWTIME 6911 +#define CT_ERROR_STOD 6925 +#define CT_ERROR_TIMETOSEC 6932 +#define CT_ERROR_TIMEVALID 6944 +#define CT_ERROR_WAITPERIOD 6954 +#define CT_ERROR_WEEK 6962 +#define CT_ERROR_WOM 6972 /* DBF functions */ -#define CT_ERROR_DBFDSKSIZE 6212 -#define CT_ERROR_DBFSIZE 6222 -#define CT_ERROR_FIELDDECI 6232 -#define CT_ERROR_FIELDNUM 6242 -#define CT_ERROR_FIELDSIZE 6252 -#define CT_ERROR_FIELDTYPE 6261 -#define CT_ERROR_ISDBT 6274 +#define CT_ERROR_DBFDSKSIZE 7112 +#define CT_ERROR_DBFSIZE 7122 +#define CT_ERROR_FIELDDECI 7132 +#define CT_ERROR_FIELDNUM 7142 +#define CT_ERROR_FIELDSIZE 7152 +#define CT_ERROR_FIELDTYPE 7161 +#define CT_ERROR_ISDBT 7174 /* switch and state functions */ -#define CT_ERROR_CSETALL 6310 /* TODO: change last digit */ -#define CT_ERROR_CSETCLIP 6320 -#define CT_ERROR_CSETDATE 6330 -#define CT_ERROR_CSETDECI 6340 -#define CT_ERROR_CSETDEFA 6350 -#define CT_ERROR_CSETFUNC 6360 -#define CT_ERROR_CSETKEY 6370 -#define CT_ERROR_CSETLDEL 6380 -#define CT_ERROR_CSETMARG 6390 -#define CT_ERROR_CSETPATH 6400 -#define CT_ERROR_CSETRDEL 6410 -#define CT_ERROR_CSETRDONLY 6420 -#define CT_ERROR_CSETSAFETY 6430 -#define CT_ERROR_CSETSNOW 6440 -#define CT_ERROR_CSETALTE 6450 -#define CT_ERROR_CSETBELL 6460 -#define CT_ERROR_CSETCARR 6470 -#define CT_ERROR_CSETCENT 6480 -#define CT_ERROR_CSETCONF 6490 -#define CT_ERROR_CSETCONS 6500 -#define CT_ERROR_CSETCURS 6510 -#define CT_ERROR_CSETDELE 6520 -#define CT_ERROR_CSETDELI 6530 -#define CT_ERROR_CSETDEVI 6540 -#define CT_ERROR_CSETESCA 6550 -#define CT_ERROR_CSETEXAC 6560 -#define CT_ERROR_CSETEXCL 6570 -#define CT_ERROR_CSETFIXE 6580 -#define CT_ERROR_CSETINTE 6590 -#define CT_ERROR_CSETPRIN 6600 -#define CT_ERROR_CSETSCOR 6610 -#define CT_ERROR_CSETSOFT 6620 -#define CT_ERROR_CSETUNIQ 6630 -#define CT_ERROR_CSETWRAP 6640 -#define CT_ERROR_ISDEBUG 6650 -#define CT_ERROR_KSETCAPS 6660 -#define CT_ERROR_KSETINS 6670 -#define CT_ERROR_KSETNUM 6680 -#define CT_ERROR_KSETSCROLL 6690 -#define CT_ERROR_LASTKFUNC 6700 -#define CT_ERROR_LASTKLINE 6710 -#define CT_ERROR_LASTKPROC 6720 -#define CT_ERROR_NUMFKEY 6730 -#define CT_ERROR_SETLASTKEY 6740 +#define CT_ERROR_CSETALL 7310 /* TODO: change last digit */ +#define CT_ERROR_CSETCLIP 7320 +#define CT_ERROR_CSETDATE 7330 +#define CT_ERROR_CSETDECI 7340 +#define CT_ERROR_CSETDEFA 7350 +#define CT_ERROR_CSETFUNC 7360 +#define CT_ERROR_CSETKEY 7370 +#define CT_ERROR_CSETLDEL 7380 +#define CT_ERROR_CSETMARG 7390 +#define CT_ERROR_CSETPATH 7400 +#define CT_ERROR_CSETRDEL 7410 +#define CT_ERROR_CSETRDONLY 7420 +#define CT_ERROR_CSETSAFETY 7430 +#define CT_ERROR_CSETSNOW 7440 +#define CT_ERROR_CSETALTE 7450 +#define CT_ERROR_CSETBELL 7460 +#define CT_ERROR_CSETCARR 7470 +#define CT_ERROR_CSETCENT 7480 +#define CT_ERROR_CSETCONF 7490 +#define CT_ERROR_CSETCONS 7500 +#define CT_ERROR_CSETCURS 7510 +#define CT_ERROR_CSETDELE 7520 +#define CT_ERROR_CSETDELI 7530 +#define CT_ERROR_CSETDEVI 7540 +#define CT_ERROR_CSETESCA 7550 +#define CT_ERROR_CSETEXAC 7560 +#define CT_ERROR_CSETEXCL 7570 +#define CT_ERROR_CSETFIXE 7580 +#define CT_ERROR_CSETINTE 7590 +#define CT_ERROR_CSETPRIN 7600 +#define CT_ERROR_CSETSCOR 7610 +#define CT_ERROR_CSETSOFT 7620 +#define CT_ERROR_CSETUNIQ 7630 +#define CT_ERROR_CSETWRAP 7640 +#define CT_ERROR_ISDEBUG 7650 +#define CT_ERROR_KSETCAPS 7660 +#define CT_ERROR_KSETINS 7670 +#define CT_ERROR_KSETNUM 7680 +#define CT_ERROR_KSETSCROLL 7690 +#define CT_ERROR_LASTKFUNC 7700 +#define CT_ERROR_LASTKLINE 7710 +#define CT_ERROR_LASTKPROC 7720 +#define CT_ERROR_NUMFKEY 7730 +#define CT_ERROR_SETLASTKEY 7740 /* system info functions */ -#define CT_ERROR_BIOSDATE 6810 /* TODO: change last digit */ -#define CT_ERROR_BOOTCOLD 6820 -#define CT_ERROR_BOOTWARM 6830 -#define CT_ERROR_CPUTYPE 6840 -#define CT_ERROR_DOSPARAM 6850 -#define CT_ERROR_ENVPARAM 6860 -#define CT_ERROR_ERRORACT 6870 -#define CT_ERROR_ERRORBASE 6880 -#define CT_ERROR_ERRORCODE 6890 -#define CT_ERROR_ERRORORG 6900 -#define CT_ERROR_EXENAME 6910 -#define CT_ERROR_FILESFREE 6920 -#define CT_ERROR_FILESMAX 6930 -#define CT_ERROR_GETCOUNTRY 6940 -#define CT_ERROR_ISANSI 6950 -#define CT_ERROR_ISAT 6960 -#define CT_ERROR_ISMATH 6970 -#define CT_ERROR_MEMSIZE 6980 -#define CT_ERROR_NUMBUFFERS 6990 -#define CT_ERROR_NUMFILES 7000 -#define CT_ERROR_OSVER 7010 -#define CT_ERROR_PCTYPE 7020 -#define CT_ERROR_SSETBREAK 7030 -#define CT_ERROR_SSETVERIFY 7040 +#define CT_ERROR_BIOSDATE 7810 /* TODO: change last digit */ +#define CT_ERROR_BOOTCOLD 7820 +#define CT_ERROR_BOOTWARM 7830 +#define CT_ERROR_CPUTYPE 7840 +#define CT_ERROR_DOSPARAM 7850 +#define CT_ERROR_ENVPARAM 7860 +#define CT_ERROR_ERRORACT 7870 +#define CT_ERROR_ERRORBASE 7880 +#define CT_ERROR_ERRORCODE 7890 +#define CT_ERROR_ERRORORG 7900 +#define CT_ERROR_EXENAME 7910 +#define CT_ERROR_FILESFREE 7920 +#define CT_ERROR_FILESMAX 7930 +#define CT_ERROR_GETCOUNTRY 7940 +#define CT_ERROR_ISANSI 7950 +#define CT_ERROR_ISAT 7960 +#define CT_ERROR_ISMATH 7970 +#define CT_ERROR_MEMSIZE 7980 +#define CT_ERROR_NUMBUFFERS 7990 +#define CT_ERROR_NUMFILES 8000 +#define CT_ERROR_OSVER 8010 +#define CT_ERROR_PCTYPE 8020 +#define CT_ERROR_SSETBREAK 8030 +#define CT_ERROR_SSETVERIFY 8040 /* 3.3 misc. functions */ -#define CT_ERROR_ALLOFREE 7110 /* TODO: change last digit */ -#define CT_ERROR_BLANK 7120 -#define CT_ERROR_COMPLEMENT 7130 -#define CT_ERROR_DATATYPE 7140 -#define CT_ERROR_GETTIC 7150 -#define CT_ERROR_KBDDISABLE 7160 -#define CT_ERROR_KBDEMULATE 7170 -#define CT_ERROR_KBDSPEED 7180 -#define CT_ERROR_KBDSTAT 7190 -#define CT_ERROR_KBDTYPE 7200 -#define CT_ERROR_KEYSEC 7210 -#define CT_ERROR_KEYTIME 7220 -#define CT_ERROR_MILLISEC 7230 -#define CT_ERROR_NUL 7240 -#define CT_ERROR_SCANKEY 7250 -#define CT_ERROR_SETTIC 7260 -#define CT_ERROR_SHOWKEY 7270 -#define CT_ERROR_SOUND 7280 -#define CT_ERROR_SPEED 7290 -#define CT_ERROR_STACKFREE 7300 -#define CT_ERROR_TOOLVER 7310 -#define CT_ERROR_XTOC 7320 +#define CT_ERROR_ALLOFREE 8110 /* TODO: change last digit */ +#define CT_ERROR_BLANK 8120 +#define CT_ERROR_COMPLEMENT 8130 +#define CT_ERROR_DATATYPE 8140 +#define CT_ERROR_GETTIC 8150 +#define CT_ERROR_KBDDISABLE 8160 +#define CT_ERROR_KBDEMULATE 8170 +#define CT_ERROR_KBDSPEED 8180 +#define CT_ERROR_KBDSTAT 8190 +#define CT_ERROR_KBDTYPE 8200 +#define CT_ERROR_KEYSEC 8210 +#define CT_ERROR_KEYTIME 8220 +#define CT_ERROR_MILLISEC 8230 +#define CT_ERROR_NUL 8240 +#define CT_ERROR_SCANKEY 8250 +#define CT_ERROR_SETTIC 8260 +#define CT_ERROR_SHOWKEY 8270 +#define CT_ERROR_SOUND 8280 +#define CT_ERROR_SPEED 8290 +#define CT_ERROR_STACKFREE 8300 +#define CT_ERROR_TOOLVER 8310 +#define CT_ERROR_XTOC 8320 /* math functions */ -#define CT_ERROR_ACOS 7413 -#define CT_ERROR_ASIN 7423 -#define CT_ERROR_ATAN 7433 -#define CT_ERROR_ATN2 7443 -#define CT_ERROR_CEILING 7452 -#define CT_ERROR_COS 7463 -#define CT_ERROR_COT 7473 -#define CT_ERROR_DTOR 7483 -#define CT_ERROR_FACT 7492 -#define CT_ERROR_FLOOR 7502 -#define CT_ERROR_FV 7513 -#define CT_ERROR_GETPREC 7522 -#define CT_ERROR_LOG10 7533 -#define CT_ERROR_PAYMENT 7543 -#define CT_ERROR_PERIODS 7552 -#define CT_ERROR_PI 7563 -#define CT_ERROR_PV 7573 -#define CT_ERROR_RATE 7583 -#define CT_ERROR_RTOD 7593 -#define CT_ERROR_SETMATHERR 7602 -#define CT_ERROR_SETPREC 7612 -#define CT_ERROR_SIGN 7622 -#define CT_ERROR_SIN 7633 -#define CT_ERROR_TAN 7643 -#define CT_ERROR_SINH 7653 -#define CT_ERROR_COSH 7663 -#define CT_ERROR_TANH 7773 +#define CT_ERROR_ACOS 8413 +#define CT_ERROR_ASIN 8423 +#define CT_ERROR_ATAN 8433 +#define CT_ERROR_ATN2 8443 +#define CT_ERROR_CEILING 8452 +#define CT_ERROR_COS 8463 +#define CT_ERROR_COT 8473 +#define CT_ERROR_DTOR 8483 +#define CT_ERROR_FACT 8492 +#define CT_ERROR_FLOOR 8502 +#define CT_ERROR_FV 8513 +#define CT_ERROR_GETPREC 8522 +#define CT_ERROR_LOG10 8533 +#define CT_ERROR_PAYMENT 8543 +#define CT_ERROR_PERIODS 8552 +#define CT_ERROR_PI 8563 +#define CT_ERROR_PV 8573 +#define CT_ERROR_RATE 8583 +#define CT_ERROR_RTOD 8593 +#define CT_ERROR_SETMATHERR 8602 +#define CT_ERROR_SETPREC 8612 +#define CT_ERROR_SIGN 8622 +#define CT_ERROR_SIN 8633 +#define CT_ERROR_TAN 8643 +#define CT_ERROR_SINH 8653 +#define CT_ERROR_COSH 8663 +#define CT_ERROR_TANH 8673 /* peek and poke functions */ -#define CT_ERROR_INBYTE 7810 /* TODO: change last digit */ -#define CT_ERROR_INWORD 7820 -#define CT_ERROR_OUTBYTE 7830 -#define CT_ERROR_OUTWORD 7840 -#define CT_ERROR_PEEKBYTE 7850 -#define CT_ERROR_PEEKSTR 7860 -#define CT_ERROR_PEEKWORD 7870 -#define CT_ERROR_POKEBYTE 7880 -#define CT_ERROR_POKEWORD 7890 +#define CT_ERROR_INBYTE 8810 /* TODO: change last digit */ +#define CT_ERROR_INWORD 8820 +#define CT_ERROR_OUTBYTE 8830 +#define CT_ERROR_OUTWORD 8840 +#define CT_ERROR_PEEKBYTE 8850 +#define CT_ERROR_PEEKSTR 8860 +#define CT_ERROR_PEEKWORD 8870 +#define CT_ERROR_POKEBYTE 8880 +#define CT_ERROR_POKEWORD 8890 /* GET/READ functions */ -#define CT_ERROR_COUNTGETS 7910 /* TODO: change last digit */ -#define CT_ERROR_CURRENTGET 7920 -#define CT_ERROR_GETFLDCOL 7930 -#define CT_ERROR_GETFLDROW 7940 -#define CT_ERROR_GETFLDVAR 7950 -#define CT_ERROR_GETINPUT 7960 -#define CT_ERROR_GETSECRET 7970 -#define CT_ERROR_RESTGETS 7980 -#define CT_ERROR_RESTSETKEY 7990 -#define CT_ERROR_SAVEGETS 8000 -#define CT_ERROR_SAVESETKEY 8010 +#define CT_ERROR_COUNTGETS 8910 /* TODO: change last digit */ +#define CT_ERROR_CURRENTGET 8920 +#define CT_ERROR_GETFLDCOL 8930 +#define CT_ERROR_GETFLDROW 8940 +#define CT_ERROR_GETFLDVAR 8950 +#define CT_ERROR_GETINPUT 8960 +#define CT_ERROR_GETSECRET 8970 +#define CT_ERROR_RESTGETS 8980 +#define CT_ERROR_RESTSETKEY 8990 +#define CT_ERROR_SAVEGETS 9000 +#define CT_ERROR_SAVESETKEY 9010 /* TODO: add network functions */ diff --git a/harbour/contrib/libct/ctflist.txt b/harbour/contrib/libct/ctflist.txt index 2a91b385a9..f092f65622 100644 --- a/harbour/contrib/libct/ctflist.txt +++ b/harbour/contrib/libct/ctflist.txt @@ -246,8 +246,8 @@ SAVETOKEN ;R; SETATLIKE ;R; STRDIFF ;N; STRSWAP ;S; -TABEXPAND ;N; -TABPACK ;N; +TABEXPAND ;S; +TABPACK ;S; TOKEN ;R; TOKENAT ;R; TOKENEND ;R; @@ -274,11 +274,11 @@ BITTOC ;S; CELSIUS ;R; CLEARBIT ;S; CTOBIT ;S; -CTOF ;N; +CTOF ;S; CTON ;S; EXPONENT ;N; FAHRENHEIT ;R; -FTOC ;N; +FTOC ;S; INFINITY ;R; INTNEG ;N; INTPOS ;N; @@ -592,7 +592,7 @@ SOUND ;N; SPEED ;N; STACKFREE ;N; TOOLVER ;N; -XTOC ;N; +XTOC ;S; ; ; ;3.4 math functions diff --git a/harbour/contrib/libct/ftoc.c b/harbour/contrib/libct/ftoc.c new file mode 100644 index 0000000000..89a577217f --- /dev/null +++ b/harbour/contrib/libct/ftoc.c @@ -0,0 +1,169 @@ +/* + * $Id$ + */ + +/* + * Harbour Project source code: + * CT3 Number and bit manipulation functions: - FTOC() + * - CTOF() + * + * Copyright 2002 Walter Negro - FOEESITRA" + * www - http://www.harbour-project.org + * + * This program 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. + * + * This program 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 this software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). + * + * As a special exception, the Harbour Project gives permission for + * additional uses of the text contained in its release of Harbour. + * + * The exception is that, if you link the Harbour libraries with other + * files to produce an executable, this does not by itself cause the + * resulting executable to be covered by the GNU General Public License. + * Your use of that executable is in no way restricted on account of + * linking the Harbour library code into it. + * + * This exception does not however invalidate any other reasons why + * the executable file might be covered by the GNU General Public License. + * + * This exception applies only to the code released by the Harbour + * Project under the name Harbour. If you copy code from other + * Harbour Project or Free Software Foundation releases into a copy of + * Harbour, as the General Public License permits, the exception does + * not apply to the code that you add in this way. To avoid misleading + * anyone as to the status of such modified files, you must delete + * this exception notice from them. + * + * If you write modifications of your own for Harbour, it is your choice + * whether to permit this exception to apply to your modifications. + * If you do not wish that, delete this exception notice. + * + */ + + +#include "ct.h" + + +/* $DOC$ + * $FUNCNAME$ + * FTOC() + * $CATEGORY$ + * CT3 number and bit manipulation functions + * $ONELINER$ + * $SYNTAX$ + * FTOC( ) --> cFloatingPointNumber + * + * $ARGUMENTS$ + * Designate any Harbour number. + * + * $RETURNS$ + * FTOC() return a string with the size of DOUBLE. + * ATTENTION: different implementations or platforms of Harbour, they + * could produce different format in the string returned by FTOC(). + * + * $DESCRIPTION$ + * Harbour internal numbers in Floating Point are stored in data type + * DOUBLE. FTOC() returns these bits as an string. In this way, + * numbers con be saved more compactly. + * + * TODO: add documentation + * $EXAMPLES$ + * $TESTS$ + * $STATUS$ + * Started + * $COMPLIANCE$ + * $PLATFORMS$ + * All + * $FILES$ + * Source is ftoc.c, library is libct. + * $SEEALSO$ + * CTOF(), XTOC() + * $END$ + */ + +HB_FUNC( FTOC ) +{ + union + { + double value; + char string[ sizeof( double )]; + } xConvert; + + xConvert.value = hb_parnd( 1 ); + + hb_retclen( xConvert.string, sizeof( double ) ); +} + + +/* $DOC$ + * $FUNCNAME$ + * CTOF() + * $CATEGORY$ + * CT3 number and bit manipulation functions + * $ONELINER$ + * $SYNTAX$ + * CTOF( ) --> nFloatingPointNumber + * + * $ARGUMENTS$ + * Designate a string that contains a Harbour + * number in flotaing point format. + * ATTENTION: different implementations or platforms of Harbour, they + * could produce different format in the string returned by FTOC(). + * + * $RETURNS$ + * CTOF() return the floating point number that corresponds to the + * string passed. + * + * $DESCRIPTION$ + * Character strings created with FTOC() or XTOC() are convert into + * Harbour floating point number + * + * TODO: add documentation + * $EXAMPLES$ + * $TESTS$ + * $STATUS$ + * Started + * $COMPLIANCE$ + * $PLATFORMS$ + * All + * $FILES$ + * Source is ftoc.c, library is libct. + * $SEEALSO$ + * FTOC(), XTOC() + * $END$ + */ + +HB_FUNC( CTOF ) +{ + union + { + double value; + char string[ sizeof( double )]; + } xConvert; + char * pcString; + int i; + + if (hb_parclen( 1 ) == sizeof( double )) + { + pcString = hb_parc( 1 ); + + for (i=0; i + * www - http://www.harbour-project.org + * + * This program 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. + * + * This program 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 this software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). + * + * As a special exception, the Harbour Project gives permission for + * additional uses of the text contained in its release of Harbour. + * + * The exception is that, if you link the Harbour libraries with other + * files to produce an executable, this does not by itself cause the + * resulting executable to be covered by the GNU General Public License. + * Your use of that executable is in no way restricted on account of + * linking the Harbour library code into it. + * + * This exception does not however invalidate any other reasons why + * the executable file might be covered by the GNU General Public License. + * + * This exception applies only to the code released by the Harbour + * Project under the name Harbour. If you copy code from other + * Harbour Project or Free Software Foundation releases into a copy of + * Harbour, as the General Public License permits, the exception does + * not apply to the code that you add in this way. To avoid misleading + * anyone as to the status of such modified files, you must delete + * this exception notice from them. + * + * If you write modifications of your own for Harbour, it is your choice + * whether to permit this exception to apply to your modifications. + * If you do not wish that, delete this exception notice. + * + */ + + +#include "ct.h" + + +/* $DOC$ + * $FUNCNAME$ + * XTOC() + * $CATEGORY$ + * CT3 miscellaneous functions + * $ONELINER$ + * $SYNTAX$ + * XTOC( ) --> cValue + * + * $ARGUMENTS$ + * Designate an expression of some of the following data + * type: NUMBER, CHARACTER, DATE, LOGICAL. + * + * $RETURNS$ + * XTOC() return a string with the representation of data type of + * expValue. + * ATTENTION: different implementations or platforms of Harbour, they + * could produce different format in the string returned by XTOC() for + * data type NUMBER. + * + * $DESCRIPTION$ + * Each data type always returns a string with a particular fixed length: + * + * ----------------------------------------------------------- + * Data Type Result Length Similar function + * ----------------------------------------------------------- + * Numeric sizeof( DOUBLE ) FTOC() + * Logical 1 + * Date 8 DTOS() + * String Unchanged + * ----------------------------------------------------------- + * + * TODO: add documentation + * $EXAMPLES$ + * $TESTS$ + * $STATUS$ + * Started + * $COMPLIANCE$ + * $PLATFORMS$ + * All + * $FILES$ + * Source is misc1.c, library is libct. + * $SEEALSO$ + * CTOF(), FTOC() + * $END$ + */ + +HB_FUNC( XTOC ) +{ + union + { + double value; + char string[ sizeof( double )]; + } xConvert; + char pcString[ sizeof( double ) ]; + + if (ISCHAR( 1 )) + { + hb_retc( hb_parc( 1 )); + } + + else if (ISNUM( 1 )) + { + xConvert.value = hb_parnd( 1 ); + hb_retclen( xConvert.string, sizeof( double ) ); + } + + else if (ISLOG( 1 )) + { + if (hb_parl( 1 ) == 0) + pcString[0] = 0x46; + else + pcString[0] = 0x54; + hb_retclen( pcString, 1 ); + } + + else if (ISDATE( 1 )) + { + hb_retc( hb_pards( 1 )); + } + + else + { + pcString[0] = 0x00; + hb_retc( pcString ); + } + + +} + diff --git a/harbour/contrib/libct/readme.txt b/harbour/contrib/libct/readme.txt index da931f39e9..488b4728d7 100644 --- a/harbour/contrib/libct/readme.txt +++ b/harbour/contrib/libct/readme.txt @@ -45,6 +45,13 @@ Martin Vogel + CTEXIT() library exit function ++ NUMANDX() \ ++ NUMORX() | ++ NUMXORX() |- equivalents to NUMAND(),... functions, but working ++ NUMNOTX() | with any bit number of 1 to 32 ++ NUMROLX() | ++ NUMMIRRX() / + * SETATLIKE() 2nd parameter can be passed by reference so that SETATLIKE can store the acutal wildcard character in it @@ -52,6 +59,9 @@ Martin Vogel + SINH() hyperbolic sine +* TABPACK() new 4th, 5th and 6th parameter to let one set the carriage-return-line-feed string, +* TABEXPAND() the tab character and the chr(141)[soft line feed] behaviour + + TANH() hyperbolic tangent * TOKEN() New 5th and 6th parameter where the function can store diff --git a/harbour/contrib/libct/remove.c b/harbour/contrib/libct/remove.c index d414351310..a984614cf2 100644 --- a/harbour/contrib/libct/remove.c +++ b/harbour/contrib/libct/remove.c @@ -101,7 +101,7 @@ static void do_remove (int iSwitch) } } - if (iSwitch != DO_REMOVE_REMRIGHT) + if (iSwitch != DO_REMOVE_REMLEFT) { pc = pcString+sStrLen-1; while ((*pc == cSearch) && (pc >= pcRet)) diff --git a/harbour/contrib/libct/tab.c b/harbour/contrib/libct/tab.c new file mode 100644 index 0000000000..15f25e901a --- /dev/null +++ b/harbour/contrib/libct/tab.c @@ -0,0 +1,593 @@ +/* + * $Id$ + */ + +/* + * Harbour Project source code: + * TABEXPAND(), TABPACK() CT3 string functions + * + * Copyright 2002 IntTec GmbH, Neunlindenstr 32, 79106 Freiburg, Germany + * Author: Martin Vogel + * + * www - http://www.harbour-project.org + * + * This program 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. + * + * This program 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 this software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). + * + * As a special exception, the Harbour Project gives permission for + * additional uses of the text contained in its release of Harbour. + * + * The exception is that, if you link the Harbour libraries with other + * files to produce an executable, this does not by itself cause the + * resulting executable to be covered by the GNU General Public License. + * Your use of that executable is in no way restricted on account of + * linking the Harbour library code into it. + * + * This exception does not however invalidate any other reasons why + * the executable file might be covered by the GNU General Public License. + * + * This exception applies only to the code released by the Harbour + * Project under the name Harbour. If you copy code from other + * Harbour Project or Free Software Foundation releases into a copy of + * Harbour, as the General Public License permits, the exception does + * not apply to the code that you add in this way. To avoid misleading + * anyone as to the status of such modified files, you must delete + * this exception notice from them. + * + * If you write modifications of your own for Harbour, it is your choice + * whether to permit this exception to apply to your modifications. + * If you do not wish that, delete this exception notice. + * + */ + + +#include "ct.h" + + +/* $DOC$ + * $FUNCNAME$ + * TABEXPAND() + * $CATEGORY$ + * CT3 string functions + * $ONELINER$ + * Replace tabulator control characters with fill characters + * $SYNTAX$ + * TABEXPAND (, [], [], + * [], [], + * []) -> cExpandedString + * $ARGUMENTS$ + * + * + * + * string indicating new line, + * default is the string returned by + * hb_osnewline() + * character indicating a tab stop, + * default is chr(9) + * .T., if the soft-CR used by MEMOEDIT() + * should be ignored as a newline indicator, + * default is .F. (functions uses chr(141)) + * $RETURNS$ + * $DESCRIPTION$ + * TODO: add documentation + * $EXAMPLES$ + * $TESTS$ + * tabexpand("-"+chr(9)+"!") == "- !" + * tabexpand("----"+chr(9) +"!") == "---- !" + * tabexpand("-"+chr(9)+"!",, "+") == "-+++++++!" + * tabexpand("-"+chr(9)+ "!", 4) == "- !" + * tabexpand("----"+chr(9)+ "!", 8) == "---- !" + * tabexpand("----"+chr(9)+ "!", 8, "+") == "----++++!" + * tabexpand("-"+chr(9)+"!"+hb_osnewline()+"----"+chr(9)+ "!",, "+") == "-+++++++!"+hb_osnewline()+"----++++!" + * $STATUS$ + * Started + * $COMPLIANCE$ + * TABEXPAND() is compatible with CT3's TABEXPAND(), but there are + * three new parameters for a better fine control of the function's + * behaviour. + * $PLATFORMS$ + * All + * $FILES$ + * Source is tab.c, library is libct. + * $SEEALSO$ + * TABPACK() + * $END$ + */ + +HB_FUNC (TABEXPAND) +{ + + if (ISCHAR (1)) + { + char *pcString = (char *)hb_parc (1); + size_t sStrLen = (size_t)hb_parclen (1); + char *pcRet; + size_t sRetLen; + size_t sTabWidth = 0; + char cFill, cTab, cCR; + char *pcNewLine; + size_t sNewLineLen; + int iIgnore141; + + size_t sIndex, sLineIndex; + size_t sTabCnt = 0; + + if (ISNUM (2)) + { + sTabWidth = hb_parnl (2); + } + if ((signed)sTabWidth <= 0) + { + sTabWidth = 8; + } + + if (ISNUM (3) || + ((ISCHAR (3)) && (hb_parclen(3)>0))) + { + if (ISNUM (3)) + { + cFill = (char)((hb_parnl (3))%256); + } + else + { + cFill = (char)(*(hb_parc (3))); + } + } + else + { + cFill = 0x20; + } + + if ((ISCHAR (4)) && (hb_parclen(4)>0)) + { + pcNewLine = (char *)hb_parc (4); + sNewLineLen = hb_parclen (4); + } + else + { + pcNewLine = hb_conNewLine(); + sNewLineLen = 0; + while (*(pcNewLine+sNewLineLen) != 0x00) + sNewLineLen++; + } + if (sNewLineLen > 0) + { + cCR = *(pcNewLine); + } + else + { + cCR = 13; + } + + if (ISNUM (5) || + ((ISCHAR (5)) && (hb_parclen(5)>0))) + { + if (ISNUM (5)) + { + cTab = (char)((hb_parnl (5))%256); + } + else + { + cTab = (char)(*(hb_parc (5))); + } + } + else + { + cTab = 0x09; + } + + if (ISLOG (6)) + { + iIgnore141 = hb_parl (6); + } + else + { + iIgnore141 = 0; + } + + /* estimate maximum return length by assuming that EVERY tab char + can be replaced by at most characters */ + for (sIndex = 0; sIndex < sStrLen; sIndex++) + { + if (*(pcString+sIndex) == cTab) + { + sTabCnt++; + } + } + pcRet = (char *)hb_xgrab (sStrLen+(sTabCnt*(sTabWidth-1))); + + /* now copy the string */ + sIndex = 0; + sRetLen = 0; + sLineIndex = 0; + while (sTabCnt > 0) + { + char cChar = (char)*(pcString+sIndex); + if (cChar == cTab) + { + /* tab character */ + size_t sFillIndex; + for (sFillIndex = sTabWidth-(sLineIndex%sTabWidth); + sFillIndex > 0; sFillIndex--) + { + *(pcRet+sRetLen) = cFill; + sRetLen++; + sLineIndex++; + } + sTabCnt--; + sIndex++; + } + else if ((unsigned char)cChar == 141) + { + /* soft carriage return */ + *(pcRet+sRetLen) = 141; + sRetLen++; + sIndex++; + if (iIgnore141) + { + sLineIndex++; + } + else + { + sLineIndex = 0; + } + } + else if (cChar == cCR) + { + /* newline string ? */ + if ((sNewLineLen > 0) && + ((sIndex+sNewLineLen) <= sStrLen) && + (ct_at_exact_forward (pcString+sIndex, sNewLineLen, + pcNewLine, sNewLineLen, NULL) == pcString+sIndex)) + { + hb_xmemcpy (pcRet+sRetLen, pcString+sIndex, sNewLineLen); + sRetLen += sNewLineLen; + sIndex += sNewLineLen; + sLineIndex = 0; + } + else + { + *(pcRet+sRetLen) = cCR; + sRetLen++; + sIndex++; + sLineIndex++; + } + } + else + { + *(pcRet+sRetLen) = *(pcString+sIndex); + sRetLen++; + sIndex++; + sLineIndex++; + } + + } + + /* copy rest */ + hb_xmemcpy (pcRet+sRetLen, pcString+sIndex, sStrLen-sIndex); + sRetLen += sStrLen-sIndex; + hb_retclen (pcRet, sRetLen); + hb_xfree (pcRet); + + } + else /* ISCHAR (1) */ + { + PHB_ITEM pSubst = NULL; + int iArgErrorMode = ct_getargerrormode(); + if (iArgErrorMode != CT_ARGERR_IGNORE) + { + pSubst = ct_error_subst ((USHORT)iArgErrorMode, EG_ARG, CT_ERROR_TABEXPAND, + NULL, "TABEXPAND", 0, EF_CANSUBSTITUTE, 6, + hb_paramError (1), hb_paramError (2), hb_paramError (3), + hb_paramError (4), hb_paramError (5), hb_paramError (6)); + } + + if (pSubst != NULL) + { + hb_itemReturn (pSubst); + hb_itemRelease (pSubst); + } + else + { + hb_retc (""); + } + } + + return; + +} + + +/* $DOC$ + * $FUNCNAME$ + * TABPACK() + * $CATEGORY$ + * CT3 string functions + * $ONELINER$ + * Pack fill characters to appropriate tab characters + * $SYNTAX$ + * TABPACK (, [], [], + * [], [], + * []) -> cPackedString + * $ARGUMENTS$ + * + * + * + * string indicating new line, + * default is the string returned by + * hb_osnewline() + * character indicating a tab stop, + * default is chr(9) + * .T., if the soft-CR used by MEMOEDIT() + * should be ignored as a newline indicator, + * default is .F. (functions uses chr(141)) + * $RETURNS$ + * $DESCRIPTION$ + * TODO: add documentation + * $EXAMPLES$ + * $TESTS$ + * $STATUS$ + * Started + * $COMPLIANCE$ + * TABPACK() is compatible with CT3's TABPACK(), but there are + * three new parameters for a better fine control of the function's + * behaviour. + * $PLATFORMS$ + * All + * $FILES$ + * Source is tab.c, library is libct. + * $SEEALSO$ + * TABEXPAND() + * $END$ + */ + +HB_FUNC (TABPACK) +{ + + if (ISCHAR (1)) + { + char *pcString = (char *)hb_parc (1); + size_t sStrLen = (size_t)hb_parclen (1); + char *pcRet; + size_t sRetLen; + size_t sTabWidth = 0; + char cFill, cTab, cCR; + char *pcNewLine; + size_t sNewLineLen; + int iIgnore141; + + size_t sIndex, sTabIndex, sFillCount; + + if (ISNUM (2)) + { + sTabWidth = hb_parnl (2); + } + if ((signed)sTabWidth <= 0) + { + sTabWidth = 8; + } + + if (ISNUM (3) || + ((ISCHAR (3)) && (hb_parclen(3)>0))) + { + if (ISNUM (3)) + { + cFill = (char)((hb_parnl (3))%256); + } + else + { + cFill = (char)(*(hb_parc (3))); + } + } + else + { + cFill = 0x20; + } + + if ((ISCHAR (4)) && (hb_parclen(4)>0)) + { + pcNewLine = (char *)hb_parc (4); + sNewLineLen = hb_parclen (4); + } + else + { + pcNewLine = hb_conNewLine(); + sNewLineLen = 0; + while (*(pcNewLine+sNewLineLen) != 0x00) + sNewLineLen++; + } + if (sNewLineLen > 0) + { + cCR = *(pcNewLine); + } + else + { + cCR = 13; + } + + if (ISNUM (5) || + ((ISCHAR (5)) && (hb_parclen(5)>0))) + { + if (ISNUM (5)) + { + cTab = (char)((hb_parnl (5))%256); + } + else + { + cTab = (char)(*(hb_parc (5))); + } + } + else + { + cTab = 0x09; + } + + if (ISLOG (6)) + { + iIgnore141 = hb_parl (6); + } + else + { + iIgnore141 = 0; + } + + /* estimate maximum return length by assuming that there's + nothing to pack */ + pcRet = (char *)hb_xgrab (sStrLen); + + /* now copy the string */ + sIndex = 0; + sRetLen = 0; + sTabIndex = 0; + sFillCount = 0; + + while (sIndex < sStrLen) + { + char cChar = (char)*(pcString+sIndex); + + if (cChar == cFill) + { + if (sTabIndex==sTabWidth-1) + { + /* we have just found the last character of a tabstopp */ + *(pcRet+sRetLen) = cTab; + sRetLen++; + sFillCount = 0; + sTabIndex = 0; + sIndex++; + } + else + { + sFillCount++; + sTabIndex++; + sIndex++; + } + } + else if (cChar == cTab) + { + *(pcRet+sRetLen) = cTab; + sRetLen++; + /* discard any fill characters before the tabstopp */ + sFillCount = 0; + sTabIndex = 0; + sIndex++; + } + else if (((unsigned char)cChar == 141) && (!iIgnore141)) + { + /* soft carriage return */ + + /* eventually not enough fill chars to fill a tab, + so copy them verbatim */ + for (;sFillCount>0;sFillCount--) + { + *(pcRet+sRetLen) = cFill; + sRetLen++; + } + *(pcRet+sRetLen) = 141; + sRetLen++; + sTabIndex = 0; + sIndex++; + } + else if (cChar == cCR) + { + /* newline string ? */ + if ((sNewLineLen > 0) && + ((sIndex+sNewLineLen) <= sStrLen) && + (ct_at_exact_forward (pcString+sIndex, sNewLineLen, + pcNewLine, sNewLineLen, NULL) == pcString+sIndex)) + { + /* eventually not enough fill chars to fill a tab, + so copy them verbatim */ + for (;sFillCount>0;sFillCount--) + { + *(pcRet+sRetLen) = cFill; + sRetLen++; + } + hb_xmemcpy (pcRet+sRetLen, pcString+sIndex, sNewLineLen); + sRetLen += sNewLineLen; + sIndex += sNewLineLen; + sTabIndex = 0; + } + else + { + *(pcRet+sRetLen) = cCR; + sRetLen++; + sIndex++; + sTabIndex = 0; + } + } + else + { + /* eventually not enough fill chars to fill a tab, + so copy them verbatim */ + for (;sFillCount>0;sFillCount--) + { + *(pcRet+sRetLen) = cFill; + sRetLen++; + sTabIndex++; + if (sTabIndex==sTabWidth-1) + { + sTabIndex = 0; + } + } + *(pcRet+sRetLen) = *(pcString+sIndex); + sRetLen++; + sIndex++; + sTabIndex++; + if (sTabIndex==sTabWidth-1) + { + sTabIndex = 0; + } + } + + } + + /* copy rest */ + for (;sFillCount>0;sFillCount--) + { + *(pcRet+sRetLen) = cFill; + sRetLen++; + } + + hb_retclen (pcRet, sRetLen); + hb_xfree (pcRet); + + } + else /* ISCHAR (1) */ + { + PHB_ITEM pSubst = NULL; + int iArgErrorMode = ct_getargerrormode(); + if (iArgErrorMode != CT_ARGERR_IGNORE) + { + pSubst = ct_error_subst ((USHORT)iArgErrorMode, EG_ARG, CT_ERROR_TABPACK, + NULL, "TABPACK", 0, EF_CANSUBSTITUTE, 6, + hb_paramError (1), hb_paramError (2), hb_paramError (3), + hb_paramError (4), hb_paramError (5), hb_paramError (6)); + } + + if (pSubst != NULL) + { + hb_itemReturn (pSubst); + hb_itemRelease (pSubst); + } + else + { + hb_retc (""); + } + } + + return; + +} diff --git a/harbour/contrib/libct/tests/Makefile b/harbour/contrib/libct/tests/Makefile index 5c5b6ef6ef..f413fffb13 100644 --- a/harbour/contrib/libct/tests/Makefile +++ b/harbour/contrib/libct/tests/Makefile @@ -71,6 +71,7 @@ PRG_SOURCES=\ num1.prg \ numtoken.prg \ setatlik.prg \ + tab.prg \ token.prg \ token2.prg \ tokenlow.prg \ diff --git a/harbour/contrib/libct/tests/tab.prg b/harbour/contrib/libct/tests/tab.prg new file mode 100644 index 0000000000..156e348f19 --- /dev/null +++ b/harbour/contrib/libct/tests/tab.prg @@ -0,0 +1,167 @@ +/* + * $Id$ + */ + +/* + * Harbour Project source code: + * Test CT3 functions TABEXPAND() and TABPACK() + * + * Copyright 2002 IntTec GmbH, Neunlindenstr 32, 79106 Freiburg, Germany + * Author: Martin Vogel + * + * www - http://www.harbour-project.org + * + * This program 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. + * + * This program 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 this software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). + * + * As a special exception, the Harbour Project gives permission for + * additional uses of the text contained in its release of Harbour. + * + * The exception is that, if you link the Harbour libraries with other + * files to produce an executable, this does not by itself cause the + * resulting executable to be covered by the GNU General Public License. + * Your use of that executable is in no way restricted on account of + * linking the Harbour library code into it. + * + * This exception does not however invalidate any other reasons why + * the executable file might be covered by the GNU General Public License. + * + * This exception applies only to the code released by the Harbour + * Project under the name Harbour. If you copy code from other + * Harbour Project or Free Software Foundation releases into a copy of + * Harbour, as the General Public License permits, the exception does + * not apply to the code that you add in this way. To avoid misleading + * anyone as to the status of such modified files, you must delete + * this exception notice from them. + * + * If you write modifications of your own for Harbour, it is your choice + * whether to permit this exception to apply to your modifications. + * If you do not wish that, delete this exception notice. + * + */ + + +#include "../ct.ch" + + +procedure main + +local cStr, nLen, ni, cStr1 + + ctinit() + + qout ("Begin test of TABEXPAND()") + qout ("") + + // simple tests + qout ("Simple tests:") + qout ([ tabexpand("-"+chr(9)+"!") == "- !" ? -> "] + tabexpand ("-"+chr(9)+"!") + ["]) + qout ([ tabexpand("----"+chr(9) +"!") == "---- !" ? -> "] + tabexpand ("----"+chr(9) +"!") + ["]) + qout ([ tabexpand("-"+chr(9)+"!",, "+") == "-+++++++!" ? -> "] + tabexpand ("-"+chr(9)+"!",, "+") + ["]) + qout ([ tabexpand("-"+chr(9)+ "!", 4) == "- !" ? -> "] + tabexpand ("-"+chr(9)+ "!", 4) + ["]) + qout ([ tabexpand("----"+chr(9)+ "!", 8) == "---- !" ? -> "] + tabexpand ("----"+chr(9)+ "!", 8) + ["]) + qout ([ tabexpand("----"+chr(9)+ "!", 8, "+") == "----++++!" ? -> "] + tabexpand ("----"+chr(9)+ "!", 8, "+") + ["]) + qout ("") + + qout ("Tests with newline characters: ^J == LF, ^M == CR") + cStr := hb_osnewline() + cStr := strtran (cStr, chr(10),"^J") + cStr := strtran (cStr, chr(13),"^M") + qout ([ hb_osnewline() = "] + cStr +["]) + cStr := tabexpand("-"+chr(9)+"!"+hb_osnewline()+"----"+chr(9)+ "!",, "+") + cStr := strtran (cStr, chr(10),"^J") + cStr := strtran (cStr, chr(13),"^M") + qout ([ tabexpand("-"+chr(9)+"!"+hb_osnewline()+"----"+chr(9)+ "!",, "+")]) + qout ([ == "-+++++++!"+hb_osnewline()+"----++++!" ? -> "] + cStr +["]) + cStr := tabexpand("-"+chr(9)+"!$$--"+hb_osnewline()+"--"+chr(9)+ "!",, "+", "$") + cStr := strtran (cStr, chr(10),"^J") + cStr := strtran (cStr, chr(13),"^M") + qout ([ tabexpand("-"+chr(9)+"!$$--"+hb_osnewline()+--"+chr(9)+ "!",, "+", "$")]) + nLen := len (hb_osnewline()) + qout ([ == "-+++++++!$$--"+hb_osnewline()+"]+replicate("-",4-nLen)+[++!" ? -> "] + cStr +["]) + qout ("") + + qout ("Tests with tab characters:") + qout ([ tabexpand("-"+chr(9)+"-",,"+") == "-+++++++-" ? -> "] + tabexpand("-"+chr(9)+"-",,"+") + ["]) + qout ([ tabexpand("-"+chr(9)+"-",,"+",,"-")]) + qout ([ == "++++++++^I+++++++" ? -> "] + strtran(tabexpand("-"+chr(9)+"-",,"+",,"-"),chr(9),"^I")+ ["]) + qout ("") + + qout ("End test of TABEXPAND()") + qout ("Press any key to continue with tests of TABPACK()...") + qout ("") + inkey (0) + + qout ("Begin test of TABPACK()") + qout ("") + + // simple tests + qout ("Simple tests: ^I == tab character") + + qout ([ tabpack("AAAAAAA*",, "*") == "AAAAAAA*" ? -> "] + strtran(tabpack("AAAAAAA*",, "*"),chr(9),"^I") + ["]) + qout ([ tabpack("AAAAA***",, "*") == "AAAAA^I" ? -> "] + strtran(tabpack("AAAAA***",, "*"),chr(9),"^I") + ["]) + qout ([ tabpack("AAAAA*****",, "*") == "AAAAA^I**" ? -> "] + strtran(tabpack("AAAAA*****",, "*"),chr(9),"^I")+ ["]) + qout ("") + + qout ("Tests with newline characters:") + cStr := hb_osnewline() + cStr := strtran (cStr, chr(10),"^J") + cStr := strtran (cStr, chr(13),"^M") + qout ([ hb_osnewline() = "] + cStr +["]) + + cStr := "ABCD+" + hb_osnewline() + "++---+++++" + cStr := tabpack (cStr, 4, "+") + cStr := strtran (cStr, chr(10),"^J") + cStr := strtran (cStr, chr(13),"^M") + cStr := strtran (cStr, chr(9),"^I") + qout ([ tabpack("ABCD+" + hb_osnewline() + "++---+++++", 4, "+")]) + qout ([ == "ABCD+"+hb_osnewline()+"++---"+chr(9)+"++" ? -> "] + cStr +["]) + + qout ("End test of TABPACK()") + qout ("") + +// qout ("Test with a MEMOEDITed string:") +// qout (" Now, a memoedit() will start. Please type a text, use tab characters") +// qout (" and make sure, you make use of soft and hard returns !") +// qout (" ...press any key to start the memoedit now...") +// qout ("") +// inkey (0) +// cls +// dispbox (0,0,20,60) +// cStr := memoedit (, 1, 1, 9, 59,,,59) +// cls +// qout (" Now printing the expanded text using a tab length of 4 and soft CRs") +// cStr1 := tabexpand (cStr,4,"+",,,.F.) +// cStr1 := strtran (cStr, chr(141), hb_osnewline()) +// +// for ni := 1 to mlcount (cStr1, 59, 4, .T.) +// qout (" "+str(ni)+": "+memoline (cStr1, 59,ni,4,.T.)) +// next ni +// +// qout (" Now printing the expanded text using a tab length of 4 but without soft CRs") +// cStr1 := tabexpand (cStr,4,"+",,,.T.) +// +// for ni := 1 to mlcount (cStr1, 59, 4, .T.) +// qout (" "+str(ni)+": "+memoline (cStr1, 59,ni,4,.T.)) +// next ni +// inkey (0) + + ctexit() + +return + + + +