From 7fbcb38a5132f56dfedb9cd47956752603c6efdc Mon Sep 17 00:00:00 2001 From: Lorenzo Fiorini Date: Thu, 20 Dec 2007 14:00:56 +0000 Subject: [PATCH] --- harbour/ChangeLog | 13 +++++ harbour/contrib/hbpgsql/postgres.c | 26 ++++++++++ harbour/contrib/hbtip/sendmail.prg | 2 +- harbour/contrib/hbtip/utils.c | 83 +++++++++++++++++++++++++++++- harbour/make_xmingw.sh | 4 +- harbour/source/rtl/hbini.prg | 9 +++- 6 files changed, 132 insertions(+), 5 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index eccac3929f..5529d2640f 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,19 @@ 2002-12-01 13:30 UTC+0100 Foo Bar */ +2007-12-20 15:00 UTC+0100 Lorenzo Fiorini (lorenzo.fiorini/at/gmail.com) + * harbour/make_xmingw.sh + * moved -maxdepth before -name + * harbour/source/rtl/hbini.prg + * added hb_ininew() + * harbour/contrib/hbtip/sendmail.prg + * removed hbcompat.ch dependences + + harbour/contrib/hbtip/utils.c + * fixed a type in jpeg mime string + * added TIP_HTMLSPECIALCHARS + + harbour/contrib/hbpgsql/postgres.c + * added PQRESULT2ARRAY + 2007-12-20 11:44 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/common.mak * harbour/source/rtl/Makefile diff --git a/harbour/contrib/hbpgsql/postgres.c b/harbour/contrib/hbpgsql/postgres.c index 32a5240382..daf62fb4ba 100644 --- a/harbour/contrib/hbpgsql/postgres.c +++ b/harbour/contrib/hbpgsql/postgres.c @@ -441,6 +441,32 @@ HB_FUNC( PQMETADATA ) } } +HB_FUNC( PQRESULT2ARRAY ) +{ + PGresult *res; + if( hb_parinfo( 1 ) ) + { + res = ( PGresult * ) hb_parptr( 1 ); + if( PQresultStatus( res ) == PGRES_TUPLES_OK ) + { + int nRows = PQntuples(res), nRow; + int nCols = PQnfields( res ), nCol; + PHB_ITEM pResult = hb_itemArrayNew( nRows ), pRow; + + for( nRow = 0; nRow < nRows ; nRow++ ) + { + pRow = hb_arrayGetItemPtr( pResult, nRow + 1 ); + hb_arrayNew ( pRow, nCols ); + for( nCol = 0; nCol < nCols ; nCol++ ) + { + hb_arraySetC( pRow, nCol + 1, PQgetvalue(res, nRow, nCol) ); + } + } + hb_itemRelease( hb_itemReturnForward( pResult ) ); + } + } +} + HB_FUNC(PQTRANSACTIONSTATUS) { if (hb_parinfo(1)) diff --git a/harbour/contrib/hbtip/sendmail.prg b/harbour/contrib/hbtip/sendmail.prg index f2516e5a69..214050d18f 100644 --- a/harbour/contrib/hbtip/sendmail.prg +++ b/harbour/contrib/hbtip/sendmail.prg @@ -116,7 +116,7 @@ FUNCTION HB_SendMail( cServer, nPort, cFrom, aTo, aCC, aBCC, cBody, cSubject, aF IF Valtype( aTo ) == "A" IF Len( aTo ) > 1 FOR EACH cTo IN aTo - IF HB_EnumIndex( cTo ) != 1 + IF cTo:__enumIndex() != 1 cTmp += cTo + "," ENDIF NEXT diff --git a/harbour/contrib/hbtip/utils.c b/harbour/contrib/hbtip/utils.c index ac6c0e3196..c905133e02 100644 --- a/harbour/contrib/hbtip/utils.c +++ b/harbour/contrib/hbtip/utils.c @@ -333,7 +333,7 @@ static MIME_ENTRY s_mimeTable[ MIME_TABLE_SIZE ] = /* 65*/ { 0, "GIF", "image/gif", 0, 0, 0 }, /* JPEG image */ - /* 66*/ { 0, "\xff\xd8", "image/x-compressed-gif", 0, 0, 0 } + /* 66*/ { 0, "\xff\xd8", "image/jpg", 0, 0, 0 } }; /* Find mime by extension */ @@ -828,3 +828,84 @@ HB_FUNC( HB_EXEC ) else hb_errRT_BASE_SubstR( EG_ARG, 1099, NULL, &hb_errFuncName, HB_ERR_ARGS_BASEPARAMS ); } + +HB_FUNC( TIP_HTMLSPECIALCHARS ) +{ + char *cData = hb_parc(1); + int nLen = hb_parclen(1); + char *cRet; + int nPos = 0, nPosRet = 0; + BYTE cElem; + + if ( ! cData ) + { + hb_errRT_BASE( EG_ARG, 3012, NULL, + "TIP_HTMLSPECIALCHARS", 1, hb_paramError(1) ); + return; + } + + if ( ! nLen ) + { + hb_retc( "" ); + return; + } + + // Giving maximum final length possible + cRet = (char *) hb_xgrab( nLen * 6 +1); + + while ( nPos < nLen ) + { + cElem = ( BYTE )cData[ nPos ]; + + if ( cElem == '&' ) + { + cRet[ nPosRet++ ] = '&'; + cRet[ nPosRet++ ] = 'a'; + cRet[ nPosRet++ ] = 'm'; + cRet[ nPosRet++ ] = 'p'; + cRet[ nPosRet++ ] = ';'; + } + else if ( cElem == '<' ) + { + cRet[ nPosRet++ ] = '&'; + cRet[ nPosRet++ ] = 'l'; + cRet[ nPosRet++ ] = 't'; + cRet[ nPosRet++ ] = ';'; + } + else if ( cElem == '>' ) + { + cRet[ nPosRet++ ] = '&'; + cRet[ nPosRet++ ] = 'g'; + cRet[ nPosRet++ ] = 't'; + cRet[ nPosRet++ ] = ';'; + } + else if ( cElem == '"' ) + { + cRet[ nPosRet++ ] = '&'; + cRet[ nPosRet++ ] = 'q'; + cRet[ nPosRet++ ] = 'u'; + cRet[ nPosRet++ ] = 'o'; + cRet[ nPosRet++ ] = 't'; + cRet[ nPosRet++ ] = ';'; + } + else if ( cElem == '\'' ) + { + cRet[ nPosRet++ ] = '&'; + cRet[ nPosRet++ ] = '#'; + cRet[ nPosRet++ ] = '0'; + cRet[ nPosRet++ ] = '3'; + cRet[ nPosRet++ ] = '9'; + cRet[ nPosRet++ ] = ';'; + } + else if ( cElem >= ' ' ) + { + cRet[ nPosRet ] = cElem; + nPosRet++; + } + + nPos++; + } + + hb_retclen_buffer( cRet, nPosRet ); +} + diff --git a/harbour/make_xmingw.sh b/harbour/make_xmingw.sh index ceb8f70b39..3151dd3bbd 100755 --- a/harbour/make_xmingw.sh +++ b/harbour/make_xmingw.sh @@ -38,9 +38,9 @@ elif [ "$UNAME" = "FreeBSD" ]; then TARGET="." CCPREFIX="" UNAMEL=bsd -elif find /usr/local/bin -name "i[3456]86-mingw*-gcc" -maxdepth 1 &>/dev/null; then +elif find /usr/local/bin -maxdepth 1 -name "i[3456]86-mingw*-gcc" &>/dev/null; then MINGW_PREFIX=/usr/local - TARGET=`find /usr/local/bin -name "i[3456]86-mingw*-gcc" -maxdepth 1|sed -e '1 !d' -e 's/.*\(i[3456]86-mingw[^-]*\).*/\1/g'` + TARGET=`find /usr/local/bin -maxdepth 1 -name "i[3456]86-mingw*-gcc" |sed -e '1 !d' -e 's/.*\(i[3456]86-mingw[^-]*\).*/\1/g'` CCPREFIX="$TARGET-" else echo "Can't determine the location for the MinGW32 cross-compiler." diff --git a/harbour/source/rtl/hbini.prg b/harbour/source/rtl/hbini.prg index 0ab7c4d399..7b575abc92 100644 --- a/harbour/source/rtl/hbini.prg +++ b/harbour/source/rtl/hbini.prg @@ -87,6 +87,14 @@ PROCEDURE hb_IniSetComment( cLc, cHlc ) s_cHalfLineComment := cHlc RETURN +FUNCTION HB_IniNew( bAutoMain ) + LOCAL hIni := hb_Hash() + + IF bAutoMain + hIni[ "MAIN" ] := hb_Hash() + ENDIF + +RETURN hIni FUNCTION hb_IniRead( cFileSpec, bKeyCaseSens, cSplitters, bAutoMain ) LOCAL hIni := hb_Hash() @@ -97,7 +105,6 @@ FUNCTION hb_IniRead( cFileSpec, bKeyCaseSens, cSplitters, bAutoMain ) DEFAULT bAutoMain TO .T. hb_HCaseMatch( hIni, bKeyCaseSens ) - hb_HAutoAdd( hIni, HB_HAUTOADD_ASSIGN ) IF bAutoMain hIni[ "MAIN" ] := hb_Hash()