Hi Francesco,

It looks okay to me.

Brgds,
Viktor

On 2008.09.29., at 15:47, Francesco Saverio Giudice wrote:

Hi Przemek, Viktor,

I would like to add hb_setSetCentury() C level function that I need to modify SET CENTURY at C level.
So there are two files involved in this change:

include/hbset.h
source/vm/set.c

I have attached a diff patch tu current SVN as proposal.
If there is no objection I will upload this changes to SVN.

(some differences because my editor trims trailing spaces)

Best regards

Francesco
Index: include/hbset.h
===================================================================
--- include/hbset.h     (revision 9514)
+++ include/hbset.h     (working copy)
@@ -254,6 +254,7 @@

extern HB_EXPORT HB_FHANDLE hb_setGetAltHan( void );
extern HB_EXPORT BOOL       hb_setGetCentury( void );
+extern HB_EXPORT BOOL       hb_setSetCentury( BOOL );
extern HB_EXPORT HB_FHANDLE hb_setGetExtraHan( void );
extern HB_EXPORT HB_FHANDLE hb_setGetPrintHan( void );
extern HB_EXPORT BOOL       hb_setGetAlternate( void );
Index: source/vm/set.c
===================================================================
--- source/vm/set.c     (revision 9514)
+++ source/vm/set.c     (working copy)
@@ -200,7 +200,7 @@
         if( pFilename->szName )
         {
            int iLen = ( int ) strlen( pFilename->szName );
-            if( ( iLen == 3 &&
+            if( ( iLen == 3 &&
                  ( hb_stricmp( pFilename->szName, "PRN" ) == 0 ||
                    hb_stricmp( pFilename->szName, "CON" ) == 0 ) ) ||
                ( iLen == 4 &&
@@ -301,34 +301,13 @@
   hb_setSetItem( HB_SET_CANCEL, hb_param( 1, HB_IT_LOGICAL ) );
}

-HB_FUNC( __SETCENTURY )
+HB_EXPORT BOOL    hb_setSetCentury( BOOL new_century_setting )
{
   PHB_SET_STRUCT pSet = hb_stackSetStruct();
   BOOL old_century_setting = pSet->hb_set_century;

+   pSet->hb_set_century = new_century_setting;
   /*
-    * Change the setting if the parameter is a logical value, or is
-    * either "ON" or "OFF" (regardless of case)
-    */
-   if( ISLOG( 1 ) )
-      pSet->hb_set_century = hb_parl( 1 );
-   else if( ISCHAR( 1 ) )
-   {
-      char * szString = hb_parc( 1 );
-      ULONG ulLen = hb_parclen( 1 );
-
-      if( ulLen >= 2
-       && toupper( ( UCHAR ) szString[ 0 ] ) == 'O'
-       && toupper( ( UCHAR ) szString[ 1 ] ) == 'N' )
-         pSet->hb_set_century = TRUE;
-      else if( ulLen >= 3
-       && toupper( ( UCHAR ) szString[ 0 ] ) == 'O'
-       && toupper( ( UCHAR ) szString[ 1 ] ) == 'F'
-       && toupper( ( UCHAR ) szString[ 2 ] ) == 'F' )
-         pSet->hb_set_century = FALSE;
-   }
-
-   /*
* Finally, if the setting changed, adjust the current date format to use
    * the correct number of year digits.
    */
@@ -394,6 +373,36 @@
   hb_retl( old_century_setting );
}

+HB_FUNC( __SETCENTURY )
+{
+   BOOL new_century_setting;
+
+   /*
+    * Change the setting if the parameter is a logical value, or is
+    * either "ON" or "OFF" (regardless of case)
+    */
+   if( ISLOG( 1 ) )
+      new_century_setting = hb_parl( 1 );
+   else if( ISCHAR( 1 ) )
+   {
+      char * szString = hb_parc( 1 );
+      ULONG ulLen = hb_parclen( 1 );
+
+      if( ulLen >= 2
+       && toupper( ( UCHAR ) szString[ 0 ] ) == 'O'
+       && toupper( ( UCHAR ) szString[ 1 ] ) == 'N' )
+         new_century_setting = TRUE;
+      else if( ulLen >= 3
+       && toupper( ( UCHAR ) szString[ 0 ] ) == 'O'
+       && toupper( ( UCHAR ) szString[ 1 ] ) == 'F'
+       && toupper( ( UCHAR ) szString[ 2 ] ) == 'F' )
+         new_century_setting = FALSE;
+   }
+
+   /* call C level function to set century */
+   return hb_setSetCentury( new_century_setting );
+}
+
HB_FUNC( SET )
{
   PHB_SET_STRUCT pSet = hb_stackSetStruct();
@@ -958,7 +967,7 @@
         /* Return NIL if called with invalid SET specifier */
         break;

-#if 0
+#if 0
      /*
* intentionally removed default: clause to enable C compiler warning
       * when not all HB_SET_* cases are implemented. [druzus]
@@ -1516,7 +1525,7 @@
         case HB_SET_HBOUTLOGINFO:
         case HB_SET_INVALID_:
            break;
-#if 0
+#if 0
         /*
* intentionally removed default: clause to enable C compiler warning
          * when not all HB_SET_* cases are implemented. [druzus]
@@ -1634,7 +1643,7 @@
      case HB_SET_HBOUTLOGINFO:
      case HB_SET_INVALID_:
         break;
-#if 0
+#if 0
      /*
* intentionally removed default: clause to enable C compiler warning
       * when not all HB_SET_* cases are implemented. [druzus]
@@ -1733,7 +1742,7 @@
      case HB_SET_TRIMFILENAME:
      case HB_SET_INVALID_:
         break;
-#if 0
+#if 0
      /*
* intentionally removed default: clause to enable C compiler warning
       * when not all HB_SET_* cases are implemented. [druzus]
@@ -1832,7 +1841,7 @@
      case HB_SET_HBOUTLOGINFO:
      case HB_SET_INVALID_:
         break;
-#if 0
+#if 0
      /*
* intentionally removed default: clause to enable C compiler warning
       * when not all HB_SET_* cases are implemented. [druzus]
_______________________________________________
Harbour mailing list
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour

_______________________________________________
Harbour mailing list
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to