From 09c05aac879054e123f9a29a976e85314160d0db Mon Sep 17 00:00:00 2001 From: Ryszard Glab Date: Fri, 7 May 2004 17:32:59 +0000 Subject: [PATCH] 2004-05-07 19:30 UTC+0100 Ryszard Glab + config/dos/owatcom.cf * added configuration file for OpenWatcom (renamed from watcom.cf) * config/dos/watcom.cf * restored previous version so it correctly compiles under WatcomC 10 - please use watcom.cf for WatcomC and owatcom.cf for OpenWatcom * makefile.bc * makefile.nt * makefile.vc * hrbdll.bc * source/codepage/Makefile + source/codepage/cdpsrwin.c + new file with Serbian codepage * CVSROOT/avail * removed reference to my local file * ERRATA * updated (removed reference to tmpname) * doc/codestyl.txt * updated with some coding guidelines adopted from PHP (please fell free to discuss them ;-) * doc/howtocvs.txt * added description for commit on Linux * include/hbapicdp.h * source/codepage/cdpesdos.c * restored previous versions * include/hbcomp.h * added reference for WatcomC compiler * include/hbexprc.c * fixed warning reported by WatcomC * source/vm/itemapi.c * fixed infinite support for WatcomC * source/rtl/cdpapi.c * renamed global symbol s_cdpage into hb_cdp_page * source/rtl/gtcrs/kbdcrs.c * fixed reporting keystrokes with codes > 127 --- CVSROOT/avail | 2 +- harbour/ChangeLog | 51 ++++++++ harbour/ERRATA | 23 ---- harbour/config/dos/owatcom.cf | 103 ++++++++++++++++ harbour/config/dos/watcom.cf | 42 ++----- harbour/doc/codestyl.txt | 155 ++++++++++++++++++++++++ harbour/doc/howtocvs.txt | 18 +++ harbour/hrbdll.bc | 4 + harbour/include/hbapicdp.h | 159 +++++++++++-------------- harbour/include/hbcomp.h | 3 + harbour/include/hbexprc.c | 14 ++- harbour/makefile.bc | 7 +- harbour/makefile.nt | 3 +- harbour/makefile.vc | 3 +- harbour/source/codepage/Makefile | 3 +- harbour/source/codepage/cdpesdos.c | 184 ++++++++++++++--------------- harbour/source/codepage/cdpsrwin.c | 175 +++++++++++++++++++++++++++ harbour/source/rtl/cdpapi.c | 15 +-- harbour/source/rtl/gtcrs/kbdcrs.c | 7 +- harbour/source/vm/itemapi.c | 31 +++-- 20 files changed, 737 insertions(+), 265 deletions(-) create mode 100644 harbour/config/dos/owatcom.cf create mode 100644 harbour/source/codepage/cdpsrwin.c diff --git a/CVSROOT/avail b/CVSROOT/avail index 73886ebe1a..bad5627557 100644 --- a/CVSROOT/avail +++ b/CVSROOT/avail @@ -1,4 +1,4 @@ unavail avail||bin,codepage,config,contrib,doc,include,lib,libs,obj,samples,source,tests,utils -avail||COPYING,ChangeLog,ChangeLog.001,ChangeLog.002,ChangeLog.003,ChangeLog.004,ChangeLog.005,ChangeLog.006,ChangeLog.007,ChangeLog.008,ChangeLog.009,ChangeLog.010,ChangeLog.011,ChangeLog.012,ChangeLog.013,ChangeLog.014,ERRATA,Makefile,TODO,cvsplay.txt,cvsplay2.txt,harbour.spec,hbchk.tgz,hbgtmk.sh,hrbdll.bc,hrbdll.vc,make_b16.bat,make_b32.bat,make_gnu.bat,make_gnu.cmd,make_gnu.sh,make_rpm.sh,make_tgz.sh,make_vc.bat,makefile.bc,makefile.nt,makefile.vc,mkbcdll.bat +avail||COPYING,ChangeLog,ChangeLog.001,ChangeLog.002,ChangeLog.003,ChangeLog.004,ChangeLog.005,ChangeLog.006,ChangeLog.007,ChangeLog.008,ChangeLog.009,ChangeLog.010,ChangeLog.011,ChangeLog.012,ChangeLog.013,ChangeLog.014,ERRATA,Makefile,TODO,cvsplay.txt,cvsplay2.txt,harbour.spec,hbgtmk.sh,hrbdll.bc,hrbdll.vc,make_b16.bat,make_b32.bat,make_gnu.bat,make_gnu.cmd,make_gnu.sh,make_rpm.sh,make_tgz.sh,make_vc.bat,makefile.bc,makefile.nt,makefile.vc,mkbcdll.bat avail|alkresin,dholm,philb,rglab diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 90e45fe6a8..0b9c4e4e27 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,57 @@ 2002-12-01 23:12 UTC+0100 Foo Bar */ +2004-05-07 19:30 UTC+0100 Ryszard Glab + + + config/dos/owatcom.cf + * added configuration file for OpenWatcom (renamed + from watcom.cf) + + * config/dos/watcom.cf + * restored previous version so it correctly compiles + under WatcomC 10 - please use watcom.cf for WatcomC + and owatcom.cf for OpenWatcom + + * makefile.bc + * makefile.nt + * makefile.vc + * hrbdll.bc + * source/codepage/Makefile + + source/codepage/cdpsrwin.c + + new file with Serbian codepage + + * CVSROOT/avail + * removed reference to my local file + + * ERRATA + * updated (removed reference to tmpname) + + * doc/codestyl.txt + * updated with some coding guidelines adopted from PHP + (please fell free to discuss them ;-) + + * doc/howtocvs.txt + * added description for commit on Linux + + * include/hbapicdp.h + * source/codepage/cdpesdos.c + * restored previous versions + + * include/hbcomp.h + * added reference for WatcomC compiler + + * include/hbexprc.c + * fixed warning reported by WatcomC + + * source/vm/itemapi.c + * fixed infinite support for WatcomC + + * source/rtl/cdpapi.c + * renamed global symbol s_cdpage into hb_cdp_page + + * source/rtl/gtcrs/kbdcrs.c + * fixed reporting keystrokes with codes > 127 + 2004-05-06 21:10 UTC-0400 David G. Holm * source/vm/itemapi.c ! The funtion snprintf is not a Standard C function and does not diff --git a/harbour/ERRATA b/harbour/ERRATA index 0f5e906582..16ac890144 100644 --- a/harbour/ERRATA +++ b/harbour/ERRATA @@ -30,26 +30,3 @@ Description........: Current known problems and wishes: ----------------------------------------------------------------------------- -Platform...........: GNU/Linux with "later" GCC/GLIBC combinations. -Noted as of release: 0.37 -Noted by...........: Dave Pearson -Severity...........: Annoyance -Bug/Wish/TODO/etc..: Design issue. -Description........: - -In GNU/Linux environments with "later" GCC/GLIBC combinations, when a user -finally links their Harbour compiled application, they see the following -advisory message: - -/usr/local/lib/harbour//librtl.a(fstemp.o): In function `hb_fsTempName': -/usr/local/src/harbour/source/rtl/linux/gcc/../../fstemp.c:73: the use of `tmpnam' is dangerous, better use `mkstemp' - -As the advisory states, the problem is that use of tmpnam is considered -"dangerous" (presumably a security issue more than anything) and Harbour's -fstemp uses tmpnam. - -Note that the executable is still built and runs fine, the message is simply -an advisory from the linker. It is worth eradicating as it seems that some -people think that the executable has failed to build. It's also worth -eradicating because the warning is probably there for a good reason. diff --git a/harbour/config/dos/owatcom.cf b/harbour/config/dos/owatcom.cf new file mode 100644 index 0000000000..31523d2c36 --- /dev/null +++ b/harbour/config/dos/owatcom.cf @@ -0,0 +1,103 @@ +# +# $Id$ +# +# The Harbour project +# GNU MAKE file for OpenWatcom C/C++ compiler + +include $(TOP)$(ROOT)config/$(HB_ARCHITECTURE)/global.cf + +OBJ_EXT = .obj +EXE_EXT = .exe +LIB_PREF = +LIB_EXT = .lib + +$(HB_ARCHITECTURE)_$(HB_COMPILER)_GRANDP = $(subst /,\,$(GRANDP)) + +CC = wpp386 +CC_IN = +CC_OUT = -fo= + +# important: -j is necessary for proper build +CPPFLAGS = -j -w3 -d2 -5s -5r -fp5 -oxehtz -zq -zt0 -bt=DOS +CFLAGS := -i$(subst /,\,$(HB_INC_COMPILE)) -i. + +# work arround to DOS command line size limit +export WPP386 := $(CPPFLAGS) +CPPFLAGS = + +ifeq ($(HB_LEX),SIMPLEX) +CFLAGS += -DSIMPLEX +endif + +# Note: The empty line directly before 'endef' HAVE TO exist! +# It causes that the 'echo' command is separated by LF +define link_file +echo FILE $(file) >> __link__.tmp + +endef + +#Note: The empty line directly before 'endef' HAVE TO exist! +define link_lib +echo LIB $(lib) >> __link__.tmp + +endef + +define link_exe_file +echo $(LDFLAGS) NAME $@ > __link__.tmp +$(foreach file, $^, $(link_file)) +$(foreach lib, $(LINKLIBS), $(link_lib)) +$(foreach lib, $(RDDLIBS), $(link_lib)) +$(foreach lib, $(GTLIBS), $(link_lib)) +-$(LD) @__link__.tmp +endef + +LD = wlink +LDFLAGS = debug all OP osn=DOS OP stack=65536 OP CASEEXACT OP stub=cwstub.exe +ifeq ($(HB_LIB_COMPILE),) +LINKLIBS := $(foreach lib, $(CONTRIBS), $(subst /,\,$(TOP)$(ROOT)contrib/$(lib)/$(ARCH)/$(subst lib,,$(lib)))) +LINKLIBS := $(foreach lib, $(LIBS), $(subst /,\,$(TOP)$(ROOT)source/$(lib)/$(ARCH)/$(lib))) +else +LINKLIBS := $(foreach lib, $(CONTRIBS), $(subst /,\,$(HB_LIB_COMPILE)/$(lib))) +LINKLIBS := $(foreach lib, $(LIBS), $(subst /,\,$(HB_LIB_COMPILE)/$(lib))) +endif + +# If LIBS specifies the rdd library, add all DB drivers. +ifeq ($(findstring rdd,$(LIBS)),rdd) +RDDLIBS := $(foreach drv, $(HB_DB_DRIVERS), $(subst /,\,$(TOP)$(ROOT)source/rdd/$(drv)/$(ARCH)/$(drv))) +endif + +ifeq ($(findstring rtl,$(LIBS)),rtl) +GTLIBS := $(TOP)$(ROOT)source/rtl/$(HB_GT_LIB)/$(ARCH)/$(HB_GT_LIB) +ifeq ($(HB_MULTI_GT),yes) +GTLIBS := $(TOP)$(ROOT)source/rtl/gtnul/$(ARCH)/gtnul +endif +GTLIBS := $(subst /,\,$(GTLIBS)) +endif + + +LD_RULE = $(link_exe_file) + +#Note: The empty line below HAVE TO exist! +define lib_object +echo -+$(file) >> __lib__.tmp + +endef + +define create_library +echo $@ > __lib__.tmp +$(foreach file, $^, $(lib_object)) +$(AR) $(ARFLAGS) @__lib__.tmp +endef + +AR = wlib +ARFLAGS = -p=32 -c $(A_USR) +AR_RULE = $(create_library) + +include $(TOP)$(ROOT)config/rules.cf + +HB := $(subst /,\,$(HB)) +HB_FLAGS := $(subst /,\,$(HB_FLAGS)) + +# work arround to DOS command line size limit +export HARBOURCMD := $(HB_FLAGS) +HB_FLAGS = diff --git a/harbour/config/dos/watcom.cf b/harbour/config/dos/watcom.cf index c97a0d0375..325feb4539 100644 --- a/harbour/config/dos/watcom.cf +++ b/harbour/config/dos/watcom.cf @@ -11,39 +11,29 @@ EXE_EXT = .exe LIB_PREF = LIB_EXT = .lib -$(HB_ARCHITECTURE)_$(HB_COMPILER)_GRANDP = $(subst /,\,$(GRANDP)) +$(HB_ARCHITECTURE)_$(HB_COMPILER)_GRANDP = $(subst /,\\,$(GRANDP)) CC = wpp386 CC_IN = CC_OUT = -fo= - -# important: -j is necessary for proper build -CPPFLAGS = -j -w3 -d2 -5s -5r -fp5 -oxehtz -zq -zt0 -bt=DOS -CFLAGS := -i$(subst /,\,$(HB_INC_COMPILE)) -i. - -# work arround to DOS command line size limit -export WPP386 := $(CPPFLAGS) -CPPFLAGS = - -ifeq ($(HB_LEX),SIMPLEX) -CFLAGS += -DSIMPLEX -endif +CPPFLAGS = -d2 -w2 -5r -zq -zt0 -bt=DOS4G +CFLAGS := -i$(subst \,\\,$(WATCOM))\\h -i$(subst /,\\,$(HB_INC_COMPILE)) -i. # Note: The empty line directly before 'endef' HAVE TO exist! # It causes that the 'echo' command is separated by LF define link_file -echo FILE $(file) >> __link__.tmp +$(COMSPEC) /E:2048 /Cecho FILE $(file) >> __link__.tmp endef #Note: The empty line directly before 'endef' HAVE TO exist! define link_lib -echo LIB $(lib) >> __link__.tmp +$(COMSPEC) /E:2048 /Cecho LIB $(lib) >> __link__.tmp endef define link_exe_file -echo $(LDFLAGS) NAME $@ > __link__.tmp +$(COMSPEC) /E:2048 /Cecho $(LDFLAGS) NAME $@ > __link__.tmp $(foreach file, $^, $(link_file)) $(foreach lib, $(LINKLIBS), $(link_lib)) $(foreach lib, $(RDDLIBS), $(link_lib)) @@ -52,7 +42,7 @@ $(foreach lib, $(GTLIBS), $(link_lib)) endef LD = wlink -LDFLAGS = debug all OP osn=DOS OP stack=65536 OP CASEEXACT OP stub=cwstub.exe +LDFLAGS = debug all OP osn=DOS4G OP stack=65536 OP CASEEXACT ifeq ($(HB_LIB_COMPILE),) LINKLIBS := $(foreach lib, $(CONTRIBS), $(subst /,\,$(TOP)$(ROOT)contrib/$(lib)/$(ARCH)/$(subst lib,,$(lib)))) LINKLIBS := $(foreach lib, $(LIBS), $(subst /,\,$(TOP)$(ROOT)source/$(lib)/$(ARCH)/$(lib))) @@ -66,38 +56,28 @@ ifeq ($(findstring rdd,$(LIBS)),rdd) RDDLIBS := $(foreach drv, $(HB_DB_DRIVERS), $(subst /,\,$(TOP)$(ROOT)source/rdd/$(drv)/$(ARCH)/$(drv))) endif -ifeq ($(findstring rtl,$(LIBS)),rtl) GTLIBS := $(TOP)$(ROOT)source/rtl/$(HB_GT_LIB)/$(ARCH)/$(HB_GT_LIB) -ifeq ($(HB_MULTI_GT),yes) -GTLIBS := $(TOP)$(ROOT)source/rtl/gtnul/$(ARCH)/gtnul -endif GTLIBS := $(subst /,\,$(GTLIBS)) -endif - LD_RULE = $(link_exe_file) #Note: The empty line below HAVE TO exist! define lib_object -echo -+$(file) >> __lib__.tmp +$(COMSPEC) /E:2048 /Cecho -+$(file) >> __lib__.tmp endef define create_library -echo $@ > __lib__.tmp +$(COMSPEC) /E:2048 /Cecho $@ > __lib__.tmp $(foreach file, $^, $(lib_object)) $(AR) $(ARFLAGS) @__lib__.tmp endef AR = wlib ARFLAGS = -p=32 -c $(A_USR) + AR_RULE = $(create_library) include $(TOP)$(ROOT)config/rules.cf -HB := $(subst /,\,$(HB)) -HB_FLAGS := $(subst /,\,$(HB_FLAGS)) - -# work arround to DOS command line size limit -export HARBOURCMD := $(HB_FLAGS) -HB_FLAGS = +HB := $(subst /,\\,$(HB)) diff --git a/harbour/doc/codestyl.txt b/harbour/doc/codestyl.txt index 2d3362747b..530ff99310 100644 --- a/harbour/doc/codestyl.txt +++ b/harbour/doc/codestyl.txt @@ -10,3 +10,158 @@ QUESTION: I had some questions at this point but I could not get an answer OPT: something is commented out to improve performance As an example: */ + +Harbour Coding Standards +======================== +(based heavily on coding standards placed in PHP) + + +Code Implementation +------------------- + +[0] Document your code in source files and the manual. [tm] + +[1] Functions that are given pointers to resources should not free them + + For instance, function int mail(char *to, char *from) should NOT free + to and/or from. + Exceptions: + + - The function's designated behavior is freeing that resource. + E.g. hb_xfree() + - The function is given a boolean argument, that controls whether or not + the function may free its arguments (if true - the function must free its + arguments, if false - it must not) + +[2] Functions that are tightly integrated with other functions within the + same module, and rely on each other non-trivial behavior, should be + documented as such and declared 'static'. They should be avoided if + possible. + +[3] Use definitions and macros whenever possible, so that constants have + meaningful names and can be easily manipulated. + Use TRUE instead of 1 (in boolean context) + Use FALSE instead of 0 (in boolean context) + Use NULL instead of 0 (in pointer context) + Always use 'HB_' prefix for definitions of new datatypes and macros. + Use either 'PHB_' prefix or '_PTR' suffix for datatypes that are + pointers. + + e.g. + HB_ITEM + PHB_ITEM + HB_ITEM_PTR + +[4] When writing functions that deal with strings, be sure to remember + that Harbour holds the length property of each string, and that it + shouldn't be calculated with strlen(). Write your functions in a such + a way so that they'll take advantage of the length property, both + for efficiency and in order for them to be binary-safe. + Functions that change strings and obtain their new lengths while + doing so, should return that new length, so it doesn't have to be + recalculated with strlen() + +[5] NEVER USE strncat(). If you're absolutely sure you know what you're doing, + check its man page again, and only then, consider using it, and even then, + try avoiding it. + + +[6] Use assert(). assert.h is included in php.h if it is available. Not only + does good assertion catch bugs, but it also helps with code readability. + - Do not use assert for error handling. Use assert only for the + condition that must be always true. + - Do not use assignments in assert conditions. If you assign inside an + assert condition, you risk an elusive bug that would be very difficult + to spot in a debug build, due to the side effect of the assignment. + Function calls in assert conditions may also cause this problem, if + they modify one of their arguments or global variables. + +[7] When commenting out code using a #if statement, do NOT use 0 only. Instead + use "_0". For example, #if FOO_0, where FOO is your + cvs user foo. This allows easier tracking of why code was commented out, + especially in bundled libraries. + + +[8] Use hb_xgrab()/hb_xalloc(), hb_xfree(), hb_xrealloc(), hb_xsize() to + manage memory allocations. These functions implement an internal + "safety-net" mechanism that ensures the deallocation of any unfreed + memory at the end of an application. They also provide useful + allocation and overflow information while running in debug mode. + +Naming Conventions +------------------ + +[1] Function names for user-level functions defined in C code should be + enclosed with in the HB_FUNC() macro. They should be in uppercase. + The name should be prefixed with 'HB_' if this function is an + extension to functions set defined in Clipper + Abbreviations should not be used when they greatly decrease the + readability of the function name itself. + + +[2] Variable names must be meaningful. One letter variable names must be + avoided, except for places where the variable has no real meaning or + a trivial meaning (e.g. for (i=0; i<100; i++) ...). + +[3] Variable names should use so-called Hungarian notation. Use lowercase + letters however use underscores to separate between words. + + Good: + pMemoryPtr + + Bad: + p_memory_ptr + +[4] Static variables should be prefixed with 's_' + +[5] Global variables (variables shared beetwen modules) should be + prefixed with 'hb_', e.g. hb_vm_bDebug, hb_gc_pStart + + +Syntax and indentation +---------------------- + +[1] Never use C++ style comments (i.e. // comment). Always use C-style + comments instead. Harbour is written in C, and is aimed at compiling + under any ANSI-C compliant compiler. Even though many compilers + accept C++-style comments in C code, you have to ensure that your + code would compile with other compilers as well. + +[2] Don't use K&R-style. Of course, we can't and don't want to + force anybody to use a style he or she is not used to, but, + at the very least, when you write code that goes into the core + of Harbour or one of its standard modules, please don't use the K&R + style. This applies to just about everything, starting with + indentation and comment styles and up to function declaration + syntax. + + (see also http://www.tuxedo.org/~esr/jargon/html/entry/indent-style.html) + +[3] Be generous with whitespace and braces. Always prefer: + + if( foo ) + { + bar; + } + + to: + + if(foo)bar; + + and to: + + if( foo ) + bar; + + Keep one empty line between the variable declaration section and + the statements in a block, as well as between logical statement + groups in a block. Maintain at least one empty line between + two functions, preferably two. + +[4] When indenting, use the tab character. A tab is expected to represent + three spaces. It is important to maintain consistency in indenture so + that definitions, comments, and control structures line up correctly. + +Documentation +-------------- + diff --git a/harbour/doc/howtocvs.txt b/harbour/doc/howtocvs.txt index fdd45b7556..fd7ed312c7 100644 --- a/harbour/doc/howtocvs.txt +++ b/harbour/doc/howtocvs.txt @@ -59,6 +59,24 @@ by Viktor Szakats 15) Send the email message containing the changes 16) Go offline (if needed) +alternative method: +by Ryszard Glab + + 1) Do the changes in the source + 2) Run CVS UPDATE redirecting the output into a file + (for example: "cvs -z3 update -d >.log" + 3) Resolve all conflicts, run cvs update again (see point 2), recompile + all sources, fix all errors + 4) Copy all names of modifed, added or deleted files (files marked with + 'M', 'A' or 'D' flag) from update log into a ChangeLog + 5) Write necessary comments in the ChangeLog + 6) Save all your changes from ChangeLog into a file + 7) Run CVS UPDATE again + 8) Commit changes running: + cvs commit -F file_with_saved_ChangeLog_changes + 9) Mail file_with_saved_ChangeLog_changes as an email body (do not + send it as an attachment) to the harbour list + Important notes: 1) *Always* add a ChangeLog entry when committing to the CVS. diff --git a/harbour/hrbdll.bc b/harbour/hrbdll.bc index c86082e06f..5986e486e8 100644 --- a/harbour/hrbdll.bc +++ b/harbour/hrbdll.bc @@ -399,6 +399,7 @@ HARBOUR_DLL_OBJS = \ $(OBJ_DIR)\cdpsl852.obj \ $(OBJ_DIR)\cdpsliso.obj \ $(OBJ_DIR)\cdpslwin.obj \ + $(OBJ_DIR)\cdpsrwin.obj \ \ $(OBJ_DIR)\external.obj @@ -2137,6 +2138,9 @@ $(OBJ_DIR)\cdpsliso.obj : $(CODEPAGE_DIR)\cdpsliso.c $(OBJ_DIR)\cdpslwin.obj : $(CODEPAGE_DIR)\cdpslwin.c $(CC) $(CLIBFLAGS) -o$@ $** +$(OBJ_DIR)\cdpsrwin.obj : $(CODEPAGE_DIR)\cdpsrwin.c + $(CC) $(CLIBFLAGS) -o$@ $** + !if $(LINK_LIBMISC) == YES $(OBJ_DIR)\hb_f.obj : $(LIBMISC_SRC)\hb_f.c diff --git a/harbour/include/hbapicdp.h b/harbour/include/hbapicdp.h index 068c8cd9d6..8aa8ef8d25 100644 --- a/harbour/include/hbapicdp.h +++ b/harbour/include/hbapicdp.h @@ -1,16 +1,54 @@ -//------------------------------------------------------------------------------ -// $Id$ -//------------------------------------------------------------------------------ -// Harbour Project source code: -// Header file for the CodePages API -//------------------------------------------------------------------------------ -// Copyright 2002 Alexander S.Kresin -// www - http://www.harbour-project.org -//------------------------------------------------------------------------------ -// LICENCE / WARRANTY DISCLAIMER: see text footer ! -//----------------------------------------------------------------------------- +/* + * $Id$ + */ -//------------------------------------------------------------------------------ +/* + * Harbour Project source code: + * Header file for the CodePages API + * + * Copyright 2002 Alexander S.Kresin + * 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. + * + */ #ifndef HB_APICDP_H_ #define HB_APICDP_H_ @@ -19,42 +57,30 @@ #include "hbapi.h" #include "hbinit.h" -//------------------------------------------------------------------------------ +/* This hack is needed to force preprocessing if id is also a macro */ +#define HB_CODEPAGE_REQUEST( id ) HB_CODEPAGE_REQUEST_( id ) +#define HB_CODEPAGE_REQUEST_( id ) \ + extern HB_FUNC( HB_CODEPAGE_##id ); \ + void hb_codepage_ForceLink( void ) \ + { \ + HB_FUNCNAME( HB_CODEPAGE_##id )(); \ + } -// 2 steps macro enables preprocessing in case "id" is a macro -#define HB_CODEPAGE_REQUEST( id ) \ - HB_CODEPAGE_REQUEST_( id ) +#define HB_CODEPAGE_ANNOUNCE( id ) HB_FUNC( HB_CODEPAGE_##id ) {} -#define HB_CODEPAGE_REQUEST_( id ) \ - extern HB_FUNC( HB_CODEPAGE_##id ); \ - void hb_codepage_ForceLink( void ) \ - { \ - HB_FUNCNAME( HB_CODEPAGE_##id )(); \ - } - -//------------------------------------------------------------------------------ - -#define HB_CODEPAGE_ANNOUNCE( id ) \ - HB_FUNC( HB_CODEPAGE_##id ) {} - -//TD3: abstract further, remove "s_codepage" dependency of macro -//TD3: check if HB_CODE_PAGE_ANNOUNCE is used, remove #define HB_CODEPAGE_INIT( id ) \ HB_CODEPAGE_ANNOUNCE( id ); \ HB_CALL_ON_STARTUP_BEGIN( hb_codepage_Init_##id ) \ hb_cdpRegister( &s_codepage ); \ HB_CALL_ON_STARTUP_END( hb_codepage_Init_##id ) -//------------------------------------------------------------------------------ typedef struct _HB_MULTICHAR { char cLast[2]; char cFirst[2]; int nCode; -} HB_MULTICHAR, *PHB_MULTICHAR; - -//------------------------------------------------------------------------------ +} HB_MULTICHAR, * PHB_MULTICHAR; typedef struct _HB_CODEPAGE { @@ -74,63 +100,14 @@ typedef struct _HB_CODEPAGE PHB_MULTICHAR multi; } HB_CODEPAGE, * PHB_CODEPAGE; -//------------------------------------------------------------------------------ - -extern BOOL hb_cdpRegister ( PHB_CODEPAGE ); -extern char* hb_cdpSelectID ( char* ); -extern PHB_CODEPAGE hb_cdpSelect ( PHB_CODEPAGE ); -extern PHB_CODEPAGE hb_cdpFind ( char* ); -extern void hb_cdpTranslate ( char*, PHB_CODEPAGE, PHB_CODEPAGE ); -extern void hb_cdpnTranslate ( char*, PHB_CODEPAGE, PHB_CODEPAGE, unsigned int ); -extern int hb_cdpcmp ( char*, char*, ULONG, PHB_CODEPAGE, ULONG* ); -extern int hb_cdpchrcmp ( char, char, PHB_CODEPAGE ); - -//------------------------------------------------------------------------------ +extern BOOL hb_cdpRegister( PHB_CODEPAGE ); +extern char * hb_cdpSelectID( char * ); +extern PHB_CODEPAGE hb_cdpSelect( PHB_CODEPAGE ); +extern PHB_CODEPAGE hb_cdpFind( char * ); +extern void hb_cdpTranslate( char*, PHB_CODEPAGE, PHB_CODEPAGE ); +extern void hb_cdpnTranslate( char*, PHB_CODEPAGE, PHB_CODEPAGE, unsigned int ); +extern int hb_cdpcmp( char*, char*, ULONG, PHB_CODEPAGE, ULONG* ); +extern int hb_cdpchrcmp( char cFirst, char cSecond, PHB_CODEPAGE cdpage ); #endif /* HB_APICDP_H_ */ -//------------------------------------------------------------------------------ -//------------------------------------------------------------------------------ -// LICENSE / WARRANTY DISCLAIMER // -//------------------------------------------------------------------------------ -// -// 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. -// -//------------------------------------------------------------------------------ \ No newline at end of file diff --git a/harbour/include/hbcomp.h b/harbour/include/hbcomp.h index 690a6061a2..71025d6562 100644 --- a/harbour/include/hbcomp.h +++ b/harbour/include/hbcomp.h @@ -58,6 +58,9 @@ #include #include #include +#if defined(__WATCOMC__) +#include /* alloca prototype */ +#endif #include "hbapi.h" #include "hberrors.h" diff --git a/harbour/include/hbexprc.c b/harbour/include/hbexprc.c index faf8c2984f..619fef1eb1 100644 --- a/harbour/include/hbexprc.c +++ b/harbour/include/hbexprc.c @@ -64,6 +64,11 @@ #include "hbcomp.h" #include "hbmacro.ch" +#ifdef __WATCOMC__ +/* disable warnings for 'no reference to symbol' */ +#pragma warning 14 9 +#endif + /* ************************************************************************* */ #if defined( HB_MACRO_SUPPORT ) @@ -472,7 +477,8 @@ BOOL hb_compExprIsValidMacro( char * szText, BOOL *pbUseTextSubst, HB_MACRO_DECL } *pbUseTextSubst |= bTextSubst; } - + HB_SYMBOL_UNUSED( HB_MACRO_PARAM ); + return bMacroText; } @@ -491,6 +497,7 @@ HB_EXPR_PTR hb_compExprReducePlusStrings( HB_EXPR_PTR pLeft, HB_EXPR_PTR pRight, pLeft->value.asString.string[ pLeft->ulLength ] = '\0'; hb_compExprFree( pRight, HB_MACRO_PARAM ); + HB_SYMBOL_UNUSED( HB_MACRO_PARAM ); /* to suppress BCC warning */ return pLeft; } #else @@ -514,3 +521,8 @@ HB_EXPR_PTR hb_compExprReducePlusStrings( HB_EXPR_PTR pLeft, HB_EXPR_PTR pRight, return pLeft; } #endif + +#ifdef __WATCOMC__ +/* enable warnings for unreferenced symbols */ +#pragma warning 14 2 +#endif diff --git a/harbour/makefile.bc b/harbour/makefile.bc index 8b38d57d6e..65db3789ab 100644 --- a/harbour/makefile.bc +++ b/harbour/makefile.bc @@ -457,7 +457,8 @@ CODEPAGE_LIB_OBJS = \ $(OBJ_DIR)\cdpsl437.obj \ $(OBJ_DIR)\cdpsl852.obj \ $(OBJ_DIR)\cdpsliso.obj \ - $(OBJ_DIR)\cdpslwin.obj + $(OBJ_DIR)\cdpslwin.obj \ + $(OBJ_DIR)\cdpsrwin.obj # # MACRO.LIB rules @@ -2356,6 +2357,10 @@ $(OBJ_DIR)\cdpslwin.obj : $(CODEPAGE_DIR)\cdpslwin.c $(CC) $(CLIBFLAGS) -o$@ $** tlib $(CODEPAGE_LIB) $(ARFLAGS) -+$@,, +$(OBJ_DIR)\cdpsrwin.obj : $(CODEPAGE_DIR)\cdpsrwin.c + $(CC) $(CLIBFLAGS) -o$@ $** + tlib $(CODEPAGE_LIB) $(ARFLAGS) -+$@,, + # # MACRO.LIB dependencies # diff --git a/harbour/makefile.nt b/harbour/makefile.nt index bea6396bd2..df8abef1c3 100644 --- a/harbour/makefile.nt +++ b/harbour/makefile.nt @@ -519,7 +519,8 @@ CODEPAGE_LIB_OBJS = \ $(OBJ_DIR)\cdpsl437.obj \ $(OBJ_DIR)\cdpsl852.obj \ $(OBJ_DIR)\cdpsliso.obj \ - $(OBJ_DIR)\cdpslwin.obj + $(OBJ_DIR)\cdpslwin.obj \ + $(OBJ_DIR)\cdpsrwin.obj # diff --git a/harbour/makefile.vc b/harbour/makefile.vc index 38ddafa59e..dfd5fff9f6 100644 --- a/harbour/makefile.vc +++ b/harbour/makefile.vc @@ -484,7 +484,8 @@ CODEPAGE_LIB_OBJS = \ $(OBJ_DIR)\cdpsl437.obj \ $(OBJ_DIR)\cdpsl852.obj \ $(OBJ_DIR)\cdpsliso.obj \ - $(OBJ_DIR)\cdpslwin.obj + $(OBJ_DIR)\cdpslwin.obj \ + $(OBJ_DIR)\cdpsrwin.obj # # MACRO.LIB rules diff --git a/harbour/source/codepage/Makefile b/harbour/source/codepage/Makefile index df658b9018..684c76da0a 100644 --- a/harbour/source/codepage/Makefile +++ b/harbour/source/codepage/Makefile @@ -23,7 +23,8 @@ C_SOURCES=\ cdpsl437.c \ cdpsl852.c \ cdpsliso.c \ - cdpslwin.c + cdpslwin.c \ + cdpsrwin.c LIBNAME=codepage diff --git a/harbour/source/codepage/cdpesdos.c b/harbour/source/codepage/cdpesdos.c index dae192afef..bcb821304d 100644 --- a/harbour/source/codepage/cdpesdos.c +++ b/harbour/source/codepage/cdpesdos.c @@ -1,109 +1,107 @@ -//----------------------------------------------------------------------------- -// $Id$ -//----------------------------------------------------------------------------- -// Harbour Project source code: -// National Collation Support Module ( Spanish MS-DOS ) -//----------------------------------------------------------------------------- -// Copyright 2002 Alexander S.Kresin -// www - http://www.harbour-project.org -//----------------------------------------------------------------------------- -// Spanish MS-DOS support by Antonio Linares -//----------------------------------------------------------------------------- -// LICENCE / WARRANTY DISCLAIMER: see text footer ! -//----------------------------------------------------------------------------- +/* + * $Id$ + */ -//----------------------------------------------------------------------------- +/* + * Harbour Project source code: + * National Collation Support Module ( Spanish MS-DOS ) + * + * Copyright 2002 Alexander S.Kresin + * www - http://www.harbour-project.org + * Spanish MS-DOS support by Antonio Linares + * + * 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. + * + */ -// Language name: Spanish //TD2: data should be moved into... -// ISO language code (2 chars): ES // ...the structure HB_CODEPAGE -// Codepage: 850 - -//----------------------------------------------------------------------------- +/* Language name: Spanish */ +/* ISO language code (2 chars): ES */ +/* Codepage: 850 */ #include #include "hbapi.h" #include "hbapicdp.h" -//----------------------------------------------------------------------------- +#define NUMBER_OF_CHARACTERS 33 /* The number of single characters in the + alphabet, two-as-one aren't considered + here, accented - are considered. */ +#define IS_LATIN 1 /* Should be 1, if the national alphabet + is based on Latin */ +#define ACCENTED_EQUAL 0 /* Should be 1, if accented character + has the same weight as appropriate + unaccented. */ +#define ACCENTED_INTERLEAVED 0 /* Should be 1, if accented characters + sort after their unaccented counterparts + only if the unaccented versions of all + characters being compared are the same + ( interleaving ) */ -#define NUMBER_OF_CHARACTERS 33 -#define IS_LATIN 1 -#define ACCENTED_EQUAL 0 -#define ACCENTED_INTERLEAVED 0 +/* If ACCENTED_EQUAL or ACCENTED_INTERLEAVED is 1, you need to mark the + accented characters with the symbol '~' before each of them, for example: + a~ + If there is two-character sequence, which is considered as one, it should + be marked with '.' before and after it, for example: + ... h.ch.i ... -//----------------------------------------------------------------------------- -// Documentation: see cdp_tpl.c + The Upper case string and the Lower case string should be absolutely the + same excepting the characters case, of course. + */ -static HB_CODEPAGE s_codepage = -{ - "ES", - NUMBER_OF_CHARACTERS, - "ABCDEFGHIJKLMNOPQRSTUVWXYZ", - "abcdefghijklmnopqrstuvwxyz", - IS_LATIN, - ACCENTED_EQUAL, - ACCENTED_INTERLEAVED, - 0, - NULL, - NULL, - NULL, - NULL, - 0, - NULL -}; +static HB_CODEPAGE s_codepage = { "ES", + NUMBER_OF_CHARACTERS, + "ABCDEFGHIJKLMNOPQRSTUVWXYZ", + "abcdefghijklmnopqrstuvwxyz", + IS_LATIN, + ACCENTED_EQUAL, + ACCENTED_INTERLEAVED, + 0, + NULL, + NULL, + NULL, + NULL, + 0, + NULL }; -//----------------------------------------------------------------------------- HB_CODEPAGE_INIT( ES ); -#ifdef HB_PRAGMA_STARTUP +#ifdef HB_USE_PRAGMA_STARTUP #pragma startup hb_codepage_Init_ES #endif - -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// LICENSE / WARRANTY DISCLAIMER -//----------------------------------------------------------------------------- -// -// 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. -// -//----------------------------------------------------------------------------- - diff --git a/harbour/source/codepage/cdpsrwin.c b/harbour/source/codepage/cdpsrwin.c new file mode 100644 index 0000000000..799a7bcc29 --- /dev/null +++ b/harbour/source/codepage/cdpsrwin.c @@ -0,0 +1,175 @@ +/* + * $Id$ + */ + +/* + + * Harbour Project source code: + + * National Collation Support Module (SRWIN) + + * + + * Copyright 2002 Alexander S.Kresin + * www - http://www.harbour-project.org + * SERBIAN collating sequence done by Srdjan Dragojlovic + + * + + * 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. + + * + + */ + + + +/* Language name: Serbian */ + +/* ISO language code (2 chars): SR */ + +/* Codepage: Windows-1251 */ + + + +#include + +#include "hbapi.h" + +#include "hbapicdp.h" + + +#define NUMBER_OF_CHARACTERS 30 /* The number of single characters in the + alphabet, two-as-one aren't considered + here, accented - are considered. */ +#define IS_LATIN 0 /* Should be 1, if the national alphabet + is based on Latin */ +#define ACCENTED_EQUAL 0 /* Should be 1, if accented character + has the same weight as appropriate + unaccented. */ +#define ACCENTED_INTERLEAVED 0 /* Should be 1, if accented characters + sort after their unaccented counterparts + only if the unaccented versions of all + characters being compared are the same + ( interleaving ) */ + +/* If ACCENTED_EQUAL or ACCENTED_INTERLEAVED is 1, you need to mark the + accented characters with the symbol '~' before each of them, for example: + a~ + If there is two-character sequence, which is considered as one, it should + be marked with '.' before and after it, for example: + ... h.ch.i ... + + The Upper case string and the Lower case string should be absolutely the + same excepting the characters case, of course. + */ + +static HB_CODEPAGE s_codepage = { "SRWIN", + NUMBER_OF_CHARACTERS, + "Āȣˊ͌Ҏ׏", + "", + + IS_LATIN, + ACCENTED_EQUAL, + ACCENTED_INTERLEAVED, + 0, + NULL, + NULL, + NULL, + NULL, + 0, + NULL }; + + +HB_CODEPAGE_ANNOUNCE( SRWIN ); + + + +HB_CALL_ON_STARTUP_BEGIN( hb_codepage_Init_SRWIN ) + + hb_cdpRegister( &s_codepage ); + +HB_CALL_ON_STARTUP_END( hb_codepage_Init_SRWIN ) + +#if ! defined(__GNUC__) && ! defined(_MSC_VER) + + #pragma startup hb_codepage_Init_SRWIN + +#endif + + + diff --git a/harbour/source/rtl/cdpapi.c b/harbour/source/rtl/cdpapi.c index 1b9196b1ef..e74491e43e 100644 --- a/harbour/source/rtl/cdpapi.c +++ b/harbour/source/rtl/cdpapi.c @@ -60,7 +60,8 @@ static HB_CODEPAGE s_en_codepage = { "EN",0,NULL,NULL,0,0,0,0,NULL,NULL,NULL,NULL,0,NULL }; static PHB_CODEPAGE s_cdpList[ HB_CDP_MAX_ ]; -PHB_CODEPAGE s_cdpage = &s_en_codepage; + +PHB_CODEPAGE hb_cdp_page = &s_en_codepage; static int hb_cdpFindPos( char * pszID ) { @@ -240,13 +241,13 @@ PHB_CODEPAGE hb_cdpFind( char * pszID ) PHB_CODEPAGE hb_cdpSelect( PHB_CODEPAGE cdpage ) { - PHB_CODEPAGE cdpOld = s_cdpage; + PHB_CODEPAGE cdpOld = hb_cdp_page; HB_TRACE(HB_TR_DEBUG, ("hb_langSelect(%p)", cdpage)); if( cdpage ) { - s_cdpage = cdpage; + hb_cdp_page = cdpage; } return cdpOld; @@ -254,7 +255,7 @@ PHB_CODEPAGE hb_cdpSelect( PHB_CODEPAGE cdpage ) char * hb_cdpSelectID( char * pszID ) { - char * pszIDOld = s_cdpage->id; + char * pszIDOld = hb_cdp_page->id; HB_TRACE(HB_TR_DEBUG, ("hb_cdpSelectID(%s)", pszID)); @@ -429,7 +430,7 @@ void hb_cdpReleaseAll( void ) HB_FUNC( HB_SETCODEPAGE ) { - hb_retc( s_cdpage->id ); + hb_retc( hb_cdp_page->id ); if( ISCHAR(1) ) hb_cdpSelectID( hb_parc( 1 ) ); @@ -448,8 +449,8 @@ HB_FUNC( HB_TRANSLATE ) if( szIn ) { ilen = hb_parclen(1); - cdpIn = ( szIdIn )? hb_cdpFind( szIdIn ):s_cdpage; - cdpOut = ( szIdOut )? hb_cdpFind( szIdOut ):s_cdpage; + cdpIn = ( szIdIn )? hb_cdpFind( szIdIn ):hb_cdp_page; + cdpOut = ( szIdOut )? hb_cdpFind( szIdOut ):hb_cdp_page; szResult = (char*) hb_xgrab( ilen + 1 ); memcpy( szResult, szIn, ilen ); szResult[ ilen ] = '\0'; diff --git a/harbour/source/rtl/gtcrs/kbdcrs.c b/harbour/source/rtl/gtcrs/kbdcrs.c index 9ae190c887..3d2ab80d96 100644 --- a/harbour/source/rtl/gtcrs/kbdcrs.c +++ b/harbour/source/rtl/gtcrs/kbdcrs.c @@ -276,9 +276,9 @@ int hb_gt_ExtendedKeySupport() int hb_gt_ReadKey( HB_inkey_enum eventmask ) { - static char key_codes[ HB_MAX_KEYMAP_CHARS + 1 ]; /* buffer for multi-characters keycodes */ + static unsigned char key_codes[ HB_MAX_KEYMAP_CHARS + 1 ]; /* buffer for multi-characters keycodes */ static int key_waiting = -1; /* position of next character from buffer if > 0 */ - int ch; + unsigned int ch; HB_TRACE(HB_TR_DEBUG, ("hb_gt_ReadKey(%d)", (int) eventmask)); @@ -306,6 +306,7 @@ int hb_gt_ReadKey( HB_inkey_enum eventmask ) int i = 0; BYTE sum; + key_codes[ 0 ] = ch; sum = ch; while( ( ch = getch() ) != ERR && i <= HB_MAX_KEYMAP_CHARS ) @@ -353,7 +354,9 @@ fflush( stderr ); } /* keymap not found */ if( i == 1 ) + { ch = key_codes[ 0 ]; + } else { key_waiting = 0; /* return raw key sequence */ diff --git a/harbour/source/vm/itemapi.c b/harbour/source/vm/itemapi.c index 14458891d6..14d5c00025 100644 --- a/harbour/source/vm/itemapi.c +++ b/harbour/source/vm/itemapi.c @@ -99,7 +99,14 @@ #include "hbmath.h" #include "hbapicdp.h" -extern PHB_CODEPAGE s_cdpage; +#if defined(__GNUC__) && defined(OS_UNIX_COMPATIBLE) + #define HB_HAS_SNPRINTF +#elif defined(__WATCOMC__) + #define HB_HAS_SNPRINTF + #define snprintf _bprintf +#endif + +extern PHB_CODEPAGE hb_cdp_page; extern char *hb_vm_sNull; extern char *hb_vm_acAscii[256]; @@ -1067,8 +1074,8 @@ int HB_EXPORT hb_itemStrCmp( PHB_ITEM pFirst, PHB_ITEM pSecond, BOOL bForceExact /* One of the strings is empty */ if( ulMinLen ) { - if( s_cdpage->lSort ) - iRet = hb_cdpcmp( szFirst,szSecond,ulMinLen,s_cdpage, &ulCounter ); + if( hb_cdp_page->lSort ) + iRet = hb_cdpcmp( szFirst,szSecond,ulMinLen,hb_cdp_page, &ulCounter ); else for( ulCounter = 0; ulCounter < ulMinLen && !iRet; ulCounter++ ) { @@ -1118,7 +1125,7 @@ BOOL HB_EXPORT hb_itemStrBuf( char *szResult, PHB_ITEM pNumber, int iSize, int i { double dNumber = hb_itemGetND( pNumber ); - #if defined(__WATCOMC__) + #if defined(__WATCOMC__) && __WATCOMC__ > 1000 #elif defined(__IBMCPP__) /* The IBM VAC++ compiler is unable to compare non-finite numbers and does not have a function to test if a number if finite. */ @@ -1168,7 +1175,7 @@ BOOL HB_EXPORT hb_itemStrBuf( char *szResult, PHB_ITEM pNumber, int iSize, int i sprintf(szResult, "%e", dNumber); #endif if( pNumber->item.asDouble.length == 99 - #if defined(__WATCOMC__) + #if defined(__WATCOMC__) && (__WATCOMC__ > 1000) || !_finite( dNumber ) #elif defined(_MSC_VER) || (__BORLANDC__ > 1040) /* Use this only above Borland C++ 3.1 */ || !_finite(dNumber) @@ -1410,22 +1417,22 @@ char * HB_EXPORT hb_itemString( PHB_ITEM pItem, ULONG * ulLen, BOOL * bFreeReq ) case HB_IT_POINTER: { - #ifdef _MSC_VER - int size = 16; /* 8 bytes for address + 0x + \0 + padding (no snprintf function) */ - #else +#ifndef HB_HAS_SNPRINTF + int size = 16; /* 8 bytes for address + 0x + \0 + padding */ +#else int size = 11; /* 8 bytes for address + 0x + \0 */ - #endif +#endif int n; BOOL bFail = TRUE; buffer = ( char * ) hb_xgrab( size ); do { - #ifdef _MSC_VER +#ifndef HB_HAS_SNPRINTF n = sprintf( buffer, "%p", hb_itemGetPtr( pItem ) ); - #else +#else n = snprintf( buffer, size, "%p", hb_itemGetPtr( pItem ) ); - #endif +#endif if( (n > -1) && (n < size) ) { bFail = FALSE;