From 941f62a32bbfb26f6b3342afd2e08a4298f77267 Mon Sep 17 00:00:00 2001 From: "David G. Holm" Date: Sat, 18 Sep 1999 04:00:30 +0000 Subject: [PATCH] See ChangeLog entry 19990917-23:45 EDT David G. Holm --- harbour/ChangeLog | 37 +++++++++ harbour/source/tools/Makefile | 1 + harbour/source/tools/osnewlin.prg | 127 +++++++++++++++++++++++++++++ harbour/tests/working/Makefile | 1 + harbour/tests/working/adirtest.prg | 11 +-- harbour/tests/working/cdow.prg | 3 +- harbour/tests/working/dates.prg | 2 +- harbour/tests/working/dates2.prg | 3 +- harbour/tests/working/dates3.prg | 2 +- harbour/tests/working/dates4.prg | 24 +++--- harbour/tests/working/dirtest.prg | 9 +- harbour/tests/working/harbour.ini | 2 +- harbour/tests/working/longdev.prg | 43 ++++++++++ harbour/tests/working/longstr2.prg | 8 +- harbour/tests/working/output.prg | 2 +- harbour/tests/working/readfile.prg | 8 +- harbour/tests/working/round.prg | 8 +- harbour/tests/working/rtl_test.prg | 24 +++--- harbour/tests/working/seconds.prg | 8 +- harbour/tests/working/set_num.prg | 4 +- harbour/tests/working/set_test.prg | 8 +- harbour/tests/working/testcgi.prg | 25 +++--- harbour/tests/working/testhtml.prg | 20 +++-- 23 files changed, 282 insertions(+), 98 deletions(-) create mode 100644 harbour/source/tools/osnewlin.prg create mode 100644 harbour/tests/working/longdev.prg diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 43b5456658..af262d2351 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,40 @@ +19990917-23:45 EDT David G. Holm + + * source/tools/Makefile + + source/tools/osnewlin.prg + + New module simplifies deciding when to use CR/LF + or just LF when using OUTSTD() and/or OUTERR() + + * tests/working/Makefile + + tests/working/longdev.prg + + I forgot to 'cvs add' this module with my earlier large string + changes, so it's a good thing that I left it out of the Makefile + + * tests/working/rtl_test.prg + + Added 3 tests for long strings (longer than 64 KB, Harbour only) + in a new function, Long_STRINGS() + + * tests/working/adirtest.prg + * tests/working/cdow.prg + * tests/working/dates.prg + * tests/working/dates2.prg + * tests/working/dates3.prg + * tests/working/dates4.prg + * tests/working/dirtest.prg + * tests/working/harbour.ini + * tests/working/longstr2.prg + * tests/working/output.prg + * tests/working/readfile.prg + * tests/working/round.prg + * tests/working/rtl_test.prg + * tests/working/seconds.prg + * tests/working/set_num.prg + * tests/working/set_test.prg + * tests/working/testcgi.prg + * tests/working/testhtml.prg + % These test programs now use OS_NewLine() + instead of using 4 different methods. + 19990917-04:58 GMT+1 Victor Szel * source/vm/hvm.c diff --git a/harbour/source/tools/Makefile b/harbour/source/tools/Makefile index 04b3360b38..c7938ea293 100644 --- a/harbour/source/tools/Makefile +++ b/harbour/source/tools/Makefile @@ -35,6 +35,7 @@ PRG_SOURCES=\ nconvert.prg \ numtxthu.prg \ numtxten.prg \ + osnewlin.prg \ stringp.prg \ LIB=tools diff --git a/harbour/source/tools/osnewlin.prg b/harbour/source/tools/osnewlin.prg new file mode 100644 index 0000000000..8213f97e11 --- /dev/null +++ b/harbour/source/tools/osnewlin.prg @@ -0,0 +1,127 @@ +/* + * $Id$ + */ + +/* + * Harbour Project source code: + * Operating System related functions + * + * Copyright 1999 David G. Holm + * 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 of the License, or + * (at your option) any later version, with one exception: + * + * The exception is that if you link the Harbour Runtime Library (HRL) + * and/or the Harbour Virtual Machine (HVM) 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 HRL + * and/or HVM code into it. + * + * 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 program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA (or visit + * their web site at http://www.gnu.org/). + * + */ + +/* ------------------------------------------------------------------------- */ + +/* + * ChangeLog: + * V 1.1 David G. Holm Committed to CVS. + * + */ + +/* ------------------------------------------------------------------------- */ + +/* $DOC$ + * $FUNCNAME$ + * OS_NewLine + * $CATEGORY$ + * Operating System Specific + * $ONELINER$ + * Returns the newline character(s) to use with the current OS + * $SYNTAX$ + * OS_NewLine( aCrLf, aLf ) --> cString + * $ARGUMENTS$ + * aCrLf can be used to add to the keyword list that is used to detect + * operating systems that require both CR and LF. The aCrLf list will + * be scanned before the default list is scanned. + * aLf can be used to force an OS that would normally be set up to + * require both CR and LF to use LF only. + * For both arguments, each element of the array must be a text string. + * Matches are made by using the $ operator with an array element as + * the left operand and the OS string as the right argument, after both + * strings have been converted to upper case. + * $RETURNS$ + * A character string containing the character or characters required + * to move the screen cursor or print head to the start of a new line. + * The string will hold either CHR( 10 ) or CHR( 13 ) + CHR( 10 ). + * $DESCRIPTION$ + * Returns a character string containing the character or characters + * required to move the screen cursor or print head to the start of a + * new line for the operating system that the program is running on + * (or thinks it is running on, if an OS emulator is being used). + * $EXAMPLES$ + * // Get the newline character(s) for the current OS using defaults. + * STATIC s_cNewLine + * ... + * s_cNewLine := OS_NewLine() + * ... + * $TESTS$ + * valtype( OS_NewLine() ) == "C" + * LEN( OS_NewLine( { "ANOTHERDOS" }, { "" } ) ) == 1 + * $STATUS$ + * C + * $COMPLIANCE$ + * This is an add-on Operating System Tool function. + * $SEEALSO$ + * OS() + * $END$ + */ + +STATIC aDefault + +FUNCTION OS_NewLine( aCrLf, aLf ) +LOCAL lCrLf, i, cOS := UPPER( OS() ) + + // Only create the default array once. + IF EMPTY( aDefault ) + // NOTE: Don't use overly permissive strings like "DOS", "NT", or "WIN" + // All alpha characters must be in UPPER CASE only! + aDefault := { "OS/2", "MS-DOS", "PC DOS", "DR DOS", "DOS 5", ; + "WINDOWS 9", "WINDOWS NT", "WINDOWS 2", "CYGWIN" } + END IF + + // First check the default CR/LF list. + lCrLf := ASCAN( aDefault, {|cEntry| cEntry $ cOS } ) > 0 + + IF ! lCrLf .AND. ! EMPTY( aCrLf ) + // Only check the extra CR/LF list if the OS wasn't already + // identified as a CR/LF OS and an extra list was provided. + lCrLf := ASCAN( aCrLf, {|cEntry| UPPER( cEntry ) $ cOS } ) > 0 + END IF + IF lCrLf .AND. ! EMPTY( aLf ) + // Only check the force LF list if it was previously determined + // that the OS would normally use CR/LF. + lCrLf := ! ASCAN( aLf, {|cEntry| UPPER( cEntry ) $ cOS } ) > 0 + END IF + + // Finally, assign and return the appropriate newline string. + IF lCrLf + // It's an OS that requires both CR and LF. + cNewLine := CHR( 13 ) + CHR( 10 ) + ELSE + // Everything else gets just LF. + cNewLine := CHR( 10 ) + END IF +RETURN cNewLine diff --git a/harbour/tests/working/Makefile b/harbour/tests/working/Makefile index 9b5e806fe3..87dbac78a0 100644 --- a/harbour/tests/working/Makefile +++ b/harbour/tests/working/Makefile @@ -78,6 +78,7 @@ PRG_SOURCES=\ instr.prg \ iotest.prg \ iotest2.prg \ + longdev.prg \ longstr.prg \ longstr2.prg \ mankala.prg \ diff --git a/harbour/tests/working/adirtest.prg b/harbour/tests/working/adirtest.prg index 56c870c236..0d92bac7cd 100644 --- a/harbour/tests/working/adirtest.prg +++ b/harbour/tests/working/adirtest.prg @@ -20,16 +20,7 @@ STATIC FUNCTION TestIt( cSpec ) LOCAL a4 LOCAL a5 - LOCAL cNewLine - - cOs := OS() - - IF "OS/2" $ OS() .OR. ; - "DOS" $ OS() - cNewLine := Chr( 13 ) + Chr( 10 ) - ELSE - cNewLine := Chr( 10 ) - ENDIF + LOCAL cNewLine := OS_NewLine() SET DATE ANSI SET CENTURY ON diff --git a/harbour/tests/working/cdow.prg b/harbour/tests/working/cdow.prg index 0635c185c3..911915dfc8 100644 --- a/harbour/tests/working/cdow.prg +++ b/harbour/tests/working/cdow.prg @@ -3,7 +3,8 @@ // function main() -local cNewLine := chr (13)+chr (10) +local cNewLine := OS_NewLine() + OutStd( cMonth( date() ) + cNewLine ) OutStd( cMonth( date() + 31 ) + cNewLine ) OutStd( cMonth( date() + 60 ) + cNewLine ) diff --git a/harbour/tests/working/dates.prg b/harbour/tests/working/dates.prg index d8cb864ff2..4fcea616ce 100644 --- a/harbour/tests/working/dates.prg +++ b/harbour/tests/working/dates.prg @@ -7,7 +7,7 @@ #include "set.ch" function Main() -local cNewLine := CHR( 13 ) + CHR( 10 ) +local cNewLine := OS_NewLine() local dDate, dDate2, cMask, cDate diff --git a/harbour/tests/working/dates2.prg b/harbour/tests/working/dates2.prg index 2d85a503de..7cc21fa280 100644 --- a/harbour/tests/working/dates2.prg +++ b/harbour/tests/working/dates2.prg @@ -4,8 +4,9 @@ #include "set.ch" function main() - local newline := CHR(13) + CHR(10) + local newline := OS_NewLine() local dDate := CTOD ("04/30/99") + outstd (SET (_SET_DATEFORMAT), dDate, newline) set (_SET_DATEFORMAT, "yyy/mm/ddd") outstd (SET (_SET_DATEFORMAT), dDate, newline) diff --git a/harbour/tests/working/dates3.prg b/harbour/tests/working/dates3.prg index 572ea96aab..62ee563336 100644 --- a/harbour/tests/working/dates3.prg +++ b/harbour/tests/working/dates3.prg @@ -8,7 +8,7 @@ function main() - LOCAL dDate, i, cNewLine := chr( 13 ) + chr( 10 ) + LOCAL dDate, i, cNewLine := OS_NewLine() set( _SET_DATEFORMAT, "dd/mm/yyyy" ) dDate := cToD( "25/05/1999" ) diff --git a/harbour/tests/working/dates4.prg b/harbour/tests/working/dates4.prg index f664fe4d3e..9e0f5ef4a3 100644 --- a/harbour/tests/working/dates4.prg +++ b/harbour/tests/working/dates4.prg @@ -5,11 +5,14 @@ // Testing Harbour dates management. #include "set.ch" -function main() +STATIC s_cNewLine +function main() LOCAL i LOCAL dDate := date() + s_cNewLine := OS_NewLine() + set( _SET_DATEFORMAT, "dd/mm/yyyy" ) for i := 7 to 49 step 7 @@ -20,16 +23,15 @@ function main() return nil function CheckDate( dDate ) - local cNewLine := chr( 13 ) + chr( 10 ) - OutStd( "Testing date:", dDate , cNewLine ) - OutStd( "Days in month..:", daysinmonth( dDate ), cNewLine ) - OutStd( "Day of year....:", doy( dDate ), cNewLine ) - OutStd( "Begin of month.:", bom( dDate ), cNewLine ) - OutStd( "End of month...:", eom( dDate ), cNewLine ) - OutStd( "Week of month..:", wom( dDate ), cNewLine ) - OutStd( "Week of year...:", woy( dDate ), cNewLine ) - OutStd( "Begin of year..:", boy( dDate ), cNewLine ) - OutStd( "End of year....:", eoy( dDate ), cNewLine ) + OutStd( "Testing date:", dDate , s_cNewLine ) + OutStd( "Days in month..:", daysinmonth( dDate ), s_cNewLine ) + OutStd( "Day of year....:", doy( dDate ), s_cNewLine ) + OutStd( "Begin of month.:", bom( dDate ), s_cNewLine ) + OutStd( "End of month...:", eom( dDate ), s_cNewLine ) + OutStd( "Week of month..:", wom( dDate ), s_cNewLine ) + OutStd( "Week of year...:", woy( dDate ), s_cNewLine ) + OutStd( "Begin of year..:", boy( dDate ), s_cNewLine ) + OutStd( "End of year....:", eoy( dDate ), s_cNewLine ) __Accept( "Press ENTER to continue..." ) OutStd( chr( 10 ), chr( 10 ) ) diff --git a/harbour/tests/working/dirtest.prg b/harbour/tests/working/dirtest.prg index 83d13dab3b..7796633d89 100644 --- a/harbour/tests/working/dirtest.prg +++ b/harbour/tests/working/dirtest.prg @@ -6,19 +6,12 @@ function main(filespec,attribs,cshort) local adir := {} -local x := 0, lShort := .f. -local cOs := OS(), cNewLine +local x := 0, lShort := .f., cNewLine := OS_NewLine() IF !cshort == NIL .and. (Upper( cShort ) == "TRUE" .or. Upper( cShort ) == ".T.") lShort := .t. ENDIF - IF "OS/2" $ cOs .OR. "WIN" $ cOs .OR. "DOS" $ cOs - cNewLine := CHR( 13 ) + CHR( 10 ) - ELSE - cNewLine := CHR( 10 ) - END IF - //adir := asort( directory(filespec,attribs,lShort),,, {|x,y|upper(x[1]) < upper(y[1])} ) adir := directory(filespec,attribs,lShort) diff --git a/harbour/tests/working/harbour.ini b/harbour/tests/working/harbour.ini index 23123e54cd..f6bb3778c9 100644 --- a/harbour/tests/working/harbour.ini +++ b/harbour/tests/working/harbour.ini @@ -8,7 +8,7 @@ so there!!!= another=section [Date Test] -Today=19990718 +Today=19990917 [Bool Test] True=.t. diff --git a/harbour/tests/working/longdev.prg b/harbour/tests/working/longdev.prg new file mode 100644 index 0000000000..497f33a3e7 --- /dev/null +++ b/harbour/tests/working/longdev.prg @@ -0,0 +1,43 @@ +// +// $Id$ +// + +// Testing Harbour long string handling with device output. +/* Harbour Project source code + http://www.Harbour-Project.org/ + Copyright 1999 David G. Holm + See doc/hdr_tpl.txt, Version 1.2 or later, for licensing terms. +*/ + +FUNCTION Main() + + LOCAL cShort := "1234567890" + LOCAL i, j, cLong, cBuffer, nHandle + + // Create an 80 KB string (Clipper is limited to 64 KB). + cLong := cShort + FOR i := 1 TO 13 + cLong += cLong + NEXT + + // Write the long string to file long_str.prn + SET PRINTER TO long_str + SET DEVICE TO PRINTER + DEVOUT( cLong ) + SET PRINTER OFF + SET DEVICE TO SCREEN + + // Confirm the string length and that a copy is exactly identical. + ? "The length of the long string is", IF( LEN( cLong ) == 80 * 1024, "correct", "wrong" ) + cBuffer := cLong + ? "The length of a copy of the long string is", IF( LEN( cLong ) == 80 * 1024, "correct", "wrong" ) + ? "The copy of the long string is", IF( cLong == cBuffer, "equal", "not equal" ), "to the long string" + + // Read the string back in and compare it to the original. + nHandle := FOPEN( "long_str.prn" ) + cBuffer := FREADSTR( nHandle, 90000 ) + ? "Original:", LEN( cLong ) + ? "From file:", LEN( cBuffer ) + ? "The strings are", IF( cLong == cBuffer, "equal", "not equal" ) + +return nil diff --git a/harbour/tests/working/longstr2.prg b/harbour/tests/working/longstr2.prg index 68884c2a10..35075ebe2e 100644 --- a/harbour/tests/working/longstr2.prg +++ b/harbour/tests/working/longstr2.prg @@ -6,14 +6,10 @@ function Main() - local short := "1234567890", cOs := OS() + local short := "1234567890" local i, long, very_long, cNewLine - IF "OS/2" $ cOs .OR. "WIN" $ cOs .OR. "DOS" $cOs - cNewLine := CHR( 13 ) + CHR( 10 ) - ELSE - cNewLine := CHR( 10 ) - END IF + cNewLine := OS_NewLine() long := short for i := 1 TO 12 diff --git a/harbour/tests/working/output.prg b/harbour/tests/working/output.prg index 4528352fdb..abea0d91d1 100644 --- a/harbour/tests/working/output.prg +++ b/harbour/tests/working/output.prg @@ -10,9 +10,9 @@ */ #include "set.ch" -#define cNewLine CHR( 13 ) + CHR( 10 ) function Main() +local cNewLine := OS_NewLine() OUTSTD (cNewLine, "Testing Harbour device management on", DATE()) SET ALTERNATE TO OUTPUT_A ADDITIVE diff --git a/harbour/tests/working/readfile.prg b/harbour/tests/working/readfile.prg index b3787d292c..1110f643cf 100644 --- a/harbour/tests/working/readfile.prg +++ b/harbour/tests/working/readfile.prg @@ -13,13 +13,7 @@ PROCEDURE Main( cFile ) LOCAL oFile := TFileRead():New( cFile ) -LOCAL cOs := UPPER( OS() ), cNewLine - - IF "OS/2" $ cOs .OR. "WIN" $ cOS .OR. "DOS" $cOS - cNewLine := CHR( 13 ) + CHR( 10 ) - ELSE - cNewLine := CHR( 10 ) - END IF +LOCAL cNewLine := OS_NewLine() oFile:Open() IF oFile:Error() diff --git a/harbour/tests/working/round.prg b/harbour/tests/working/round.prg index d0ddab5059..3f81693ed0 100644 --- a/harbour/tests/working/round.prg +++ b/harbour/tests/working/round.prg @@ -11,13 +11,7 @@ function main() local n, value := -5 -local cOs := OS(), cNewLine - - IF "OS/2" $ cOs .OR. "WIN" $ cOs .OR. "DOS" $cOs - cNewLine := CHR( 13 ) + CHR( 10 ) - ELSE - cNewLine := CHR( 10 ) - END IF +local cNewLine := OS_NewLine() for n := 1 to 100 OUTSTD(cNewLine) diff --git a/harbour/tests/working/rtl_test.prg b/harbour/tests/working/rtl_test.prg index b4a6d8a3bd..910eb46ab8 100644 --- a/harbour/tests/working/rtl_test.prg +++ b/harbour/tests/working/rtl_test.prg @@ -135,6 +135,9 @@ FUNCTION Main( cPar1, cPar2 ) Main_HVM() Main_MATH() Main_STRINGS() +#ifdef __HARBOUR__ + Long_STRINGS() +#endif Main_MISC() #ifdef __HARBOUR__ Main_OPOVERL() @@ -1507,6 +1510,16 @@ STATIC FUNCTION Main_STRINGS() RETURN NIL +#ifdef __HARBOUR__ +STATIC FUNCTION Long_STRINGS() + + TEST_LINE( RIGHT( SPACE( 64 * 1024 - 5 ) + "12345 7890", 10 ), "12345 7890" ) + TEST_LINE( LEN( SPACE( 81910 ) + "1234567890" ), 81920 ) + TEST_LINE( ( "1234567890" + SPACE( 810910 ) ) - ( "1234567890" + SPACE( 810910 ) ), "12345678901234567890" + SPACE( 810910 * 2 ) ) + + RETURN NIL +#endif + STATIC FUNCTION Main_MISC() /* EVAL(), :EVAL */ @@ -2046,18 +2059,10 @@ STATIC FUNCTION Main_LAST() RETURN NIL STATIC FUNCTION TEST_BEGIN( cParam ) - LOCAL cOs s_nStartTime := Seconds() - cOs := OS() - - IF "OS/2" $ cOs .OR. ; - "DOS" $ cOs - s_cNewLine := Chr( 13 ) + Chr( 10 ) - ELSE - s_cNewLine := Chr( 10 ) - ENDIF + s_cNewLine := OS_NewLine() s_lShowAll := "/ALL" $ Upper( cParam ) s_aSkipList := ListToNArray( CMDLGetValue( Upper( cParam ), "/SKIP:", "" ) ) @@ -2485,4 +2490,3 @@ STATIC FUNCTION SToD( cDate ) #endif #endif - diff --git a/harbour/tests/working/seconds.prg b/harbour/tests/working/seconds.prg index 0579b3ad58..863aba9ec1 100644 --- a/harbour/tests/working/seconds.prg +++ b/harbour/tests/working/seconds.prg @@ -11,13 +11,7 @@ function Main( cParam ) local n, limit := 10 -local cOs := OS(), cNewLine - - IF "OS/2" $ cOs .OR. "WIN" $ cOs .OR. "DOS" $ cOs - cNewLine := CHR( 13 ) + CHR( 10 ) - ELSE - cNewLine := CHR( 10 ) - END IF +local cNewLine := OS_NewLine() IF( ! EMPTY( cParam ) ) limit := VAL( cParam ) diff --git a/harbour/tests/working/set_num.prg b/harbour/tests/working/set_num.prg index 2e8b6b947a..269794923b 100644 --- a/harbour/tests/working/set_num.prg +++ b/harbour/tests/working/set_num.prg @@ -5,10 +5,10 @@ // Testing SET function Main() -local n, NEWLINE := CHR (10) + CHR(13) +local n, cNewLine := OS_NewLine() for n := 1 to 39 - outstd (NEWLINE) + outstd (cNewLine) outstd (set (n)) next diff --git a/harbour/tests/working/set_test.prg b/harbour/tests/working/set_test.prg index 7f158ca4ec..0129582c10 100644 --- a/harbour/tests/working/set_test.prg +++ b/harbour/tests/working/set_test.prg @@ -4,11 +4,16 @@ // Testing SET +STATIC s_cNewLine + #include "set.ch" request dbfntx function Main() // for Clipper, this drags in the terminal driver @ Row(), col() say "" + + s_cNewLine := OS_NewLine() + TestLine( "_SET_EXACT", 1) TestLine( "_SET_FIXED", 2) TestLine( "_SET_DECIMALS", 3) @@ -60,8 +65,7 @@ function Main() return nil proc testline( c, n ) -local NEWLINE := CHR (13) + CHR (10) -outstd( NEWLINE ) +outstd( s_cNewLine ) outstd( str( n, 3 ) ) outstd( " "+Padr( c, 17 ) ) outstd( Set( n ) ) diff --git a/harbour/tests/working/testcgi.prg b/harbour/tests/working/testcgi.prg index e758a83aee..8953c0c4fc 100644 --- a/harbour/tests/working/testcgi.prg +++ b/harbour/tests/working/testcgi.prg @@ -27,17 +27,16 @@ #include "cgi.ch" #define IF_BUFFER 65535 -#ifdef __HARBOUR__ -#define NewLine chr(10) -#else -#define NewLine chr(13) -#endif + +STATIC s_cNewLine FUNCTION Main() LOCAL oHTML := THTML():New() LOCAL hFile, nPos, cString, cBuf, i, cTable, cLine + s_cNewLine := OS_NewLine() + oHTML:SetHTMLFile( "function.cfm" ) hFile := fOpen( "list.txt", 0 ) @@ -247,8 +246,8 @@ STATIC FUNCTION AddPara( cPara, cAlign ) LOCAL Self := QSelf() ::cBody := ::cBody + ; - "

" + NewLine + ; - cPara + NewLine + ; + "

" + s_cNewLine + ; + cPara + s_cNewLine + ; "

" RETURN( Self ) @@ -262,11 +261,11 @@ STATIC FUNCTION Generate() // Is this a meta file or hand generated script? IF empty( ::cHTMLFile ) ::cContent := ; - "" + NewLine + ; - "" + ::cTitle + "" + NewLine + ; + "" + s_cNewLine + ; + "" + ::cTitle + "" + s_cNewLine + ; "" + + NewLine + ; - ::cBody + NewLine + ; + "vlink='" + ::cvLinkColor + "'>" + + s_cNewLine + ; + ::cBody + s_cNewLine + ; "" ELSE ::cContent := "" @@ -326,8 +325,8 @@ STATIC FUNCTION ShowResult() LOCAL Self := QSelf() OutStd( ; - "HTTP/1.0 200 OK" + NewLine + ; - "CONTENT-TYPE: TEXT/HTML" + NewLine + NewLine + ; + "HTTP/1.0 200 OK" + s_cNewLine + ; + "CONTENT-TYPE: TEXT/HTML" + s_cNewLine + s_cNewLine + ; ::cContent ) RETURN( Self ) diff --git a/harbour/tests/working/testhtml.prg b/harbour/tests/working/testhtml.prg index 048f5ad653..7f0cf66717 100644 --- a/harbour/tests/working/testhtml.prg +++ b/harbour/tests/working/testhtml.prg @@ -15,12 +15,14 @@ * **/ -#define NewLine chr(10)+chr(13) +STATIC s_cNewLine FUNCTION Main() LOCAL oHTML := THTML():New() + s_cNewLine := OS_NewLine() + oHTML:SetTitle( "Harbour Power Demonstration" ) oHTML:AddHead( "Harbour Project" ) oHTML:AddPara( "Harbour is xBase at its best. Have a taste today!", "LEFT" ) @@ -119,8 +121,8 @@ STATIC FUNCTION AddPara( cPara, cAlign ) Default( cAlign, "Left" ) ::cBody := ::cBody + ; - "

" + NewLine + ; - cPara + NewLine + ; + "

" + s_cNewLine + ; + cPara + s_cNewLine + ; "

" RETURN( Self ) @@ -130,11 +132,11 @@ STATIC FUNCTION Generate() LOCAL Self := QSelf() ::cContent := ; - "" + NewLine + ; - "" + ::cTitle + "" + NewLine + ; + "" + s_cNewLine + ; + "" + ::cTitle + "" + s_cNewLine + ; "" + + NewLine + ; - ::cBody + NewLine + ; + "vlink='" + ::cvLinkColor + "'>" + + s_cNewLine + ; + ::cBody + s_cNewLine + ; "" RETURN( Self ) @@ -144,8 +146,8 @@ STATIC FUNCTION ShowResult() LOCAL Self := QSelf() qqOut( ; - "HTTP/1.0 200 OK" + NewLine + ; - "CONTENT-TYPE: TEXT/HTML" + NewLine + NewLine + ; + "HTTP/1.0 200 OK" + s_cNewLine + ; + "CONTENT-TYPE: TEXT/HTML" + s_cNewLine + s_cNewLine + ; ::cContent ) RETURN( Self )