Changeset 245


Ignore:
Timestamp:
Feb 2, 2003, 9:22:17 PM (23 years ago)
Author:
umoeller
Message:

Sources as of 1.0.1.

Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/helpers/stringh.h

    r240 r245  
    7272                             ULONG cbSource);
    7373
     74    size_t XWPENTRY strlcpy(char *dst,
     75                            const char *src,
     76                            size_t siz);
     77
     78    size_t strlcat(char *dst,
     79                   const char *src,
     80                   size_t siz);
     81
    7482    ULONG XWPENTRY strhlen(PCSZ pcsz);
    7583
     
    144152                             PCSZ pcszSource);
    145153
     154    BOOL XWPENTRY strhKillChar(PSZ psz,
     155                               CHAR c,
     156                               PULONG pulLength);
     157
    146158    PSZ XWPENTRY strhFindAttribValue(const char *pszSearchIn, const char *pszAttrib);
    147159
  • trunk/include/helpers/winh.h

    r243 r245  
    7878    #endif
    7979
     80    #ifndef PP_FIELDBACKGROUNDCOLOR
     81    #define PP_FIELDBACKGROUNDCOLOR                 57L
     82    #endif
     83
     84    #ifndef PP_PAGEFOREGROUNDCOLOR
     85    #define PP_PAGEFOREGROUNDCOLOR                  68L
     86    #endif
     87
     88    #ifndef PP_PAGEBACKGROUNDCOLOR
     89    #define PP_PAGEBACKGROUNDCOLOR                  69L
     90    #endif
     91
     92    #ifndef CM_SETGRIDINFO
     93    #define CM_SETGRIDINFO                0x0354
     94    #define CM_QUERYGRIDINFO              0x0355
     95    #define CM_SNAPTOGRID                 0x0356
     96    #define CRA_LOCKED          0x00000400L /* record is locked.          */
     97    #endif
     98
    8099    /* ******************************************************************
    81100     *
  • trunk/make/link_exe.in

    r243 r245  
    6565$(MODULESDIR)\$(MODULESTEM).exe: $(LINKOBJS) $(MODULEDEF) $(DEPEND_RES)
    6666    @echo   ### [$@]: Linking $(@F)
    67     $(LINK) /OUT:$@ $(MODULEDEF) $(LINKOBJS) $(PMPRINTF_LIB)
     67    $(LINK) @<<
     68/OUT:$@ $(MODULEDEF) $(LINKOBJS) $(PMPRINTF_LIB)
     69<<KEEP
    6870!ifdef DEPEND_RES
    6971    @echo   ### [$@]: Appending $(@B).res
  • trunk/src/helpers/_call_filedlg.c

    r243 r245  
    400400        PGROUPRECORD preccFirst;
    401401
     402        CHAR    szTest[12];
     403        ULONG   len;
     404
     405        len = strlcpy(szTest, "~Group name", sizeof(szTest));
     406        strhKillChar(szTest, '~', &len);
     407
    402408        // set up cnr details view
    403409        xfi[i].ulFieldOffset = FIELDOFFSET(GROUPRECORD, gid);
     
    407413
    408414        xfi[i].ulFieldOffset = FIELDOFFSET(GROUPRECORD, recc.pszIcon);
    409         xfi[i].pszColumnTitle = "Group name";   // @@todo localize
     415        xfi[i].pszColumnTitle = szTest; // "Group name";   // @@todo localize
    410416        xfi[i].ulDataType = CFA_STRING;
    411417        xfi[i++].ulOrientation = CFA_CENTER;
  • trunk/src/helpers/cctl_cnr.c

    r243 r245  
    486486            }
    487487
    488             _PmpfF(("cyColTitlesBox %d, new cy: %d", pData->cyColTitlesBox, cy));
    489 
    490488            if (fl & DDFL_WINDOWSIZECHANGED)
    491489                WinSetWindowPos(pData->dwdContent.hwnd,
     
    508506                                cy,
    509507                                SWP_MOVE | SWP_SIZE);
    510 
    511                 _PmpfF(("updating VScroll, cy: %d, scrw.szlWorkarea.cy: %d",
    512                         cy,
    513                         pData->scrw.szlWorkarea.cy));
    514508            }
    515509
     
    523517                                pData->scrw.cyScrollBar,
    524518                                SWP_MOVE | SWP_SIZE);
    525 
    526                 _PmpfF(("updating HScroll, cx: %d, scrw.szlWorkarea.cx: %d",
    527                         cx,
    528                         pData->scrw.szlWorkarea.cx));
    529519            }
    530520
  • trunk/src/helpers/makefile

    r243 r245  
    8989!include helpers_pre.in
    9090
    91 # The main target:
    92 # If we're called from the main makefile, MAINMAKERUNNING is defined,
    93 # and we'll set $(OBJS) as our targets (which will go on).
    94 # Otherwise, we call the main makefile, which will again call ourselves later.
    95 
    96 all:   \
    97 !ifndef MAINMAKERUNNING
    98     callmainmake
    99     @echo ----- Leaving $(MAKEDIR)
    100 !else
    101     $(OUTPUTDIR)\helpers.lib
    102 #$(OBJS)
    103     @echo ----- Leaving $(MAKEDIR)
    104 !endif
    105 
    10691plainc:   \
    10792!ifndef MAINMAKERUNNING
     
    123108    @echo ----- Leaving $(MAKEDIR)
    124109!endif
    125 
    126 
    127 callmainmake:
    128     @echo $(MAKEDIR)\makefile: Recursing to main makefile.
    129     @cd $(PROJECT_BASE_DIR)
    130     @nmake
    131     @echo $(MAKEDIR)\makefile: Returned from main makefile. Done.
    132 
    133 # The "dep" target: run fastdep on the sources.
    134 # "nmake dep" gets called from src\makefile if nmake dep
    135 # is running on the main makefile.
    136 dep:
    137     $(RUN_FASTDEP) *.c
    138     @echo ----- Leaving $(MAKEDIR)
    139110
    140111# Define the main dependency between the output HELPERS.LIB and
     
    181152
    182153!include helpers_post.in
     154
     155ALLTARGET = $(OUTPUTDIR)\helpers.lib
     156
     157!include ..\..\make\targets.in
    183158
    184159###################################################
  • trunk/src/helpers/stringh.c

    r242 r245  
    409409
    410410    return ul;
     411}
     412
     413/*
     414 *@@ strlcpy:
     415 *      copies src to string dst of size siz.  At most siz-1 characters
     416 *      will be copied.  Always NUL terminates, unless siz == 0.
     417 *
     418 *      Returns strlen(src); if retval >= siz, truncation occurred.
     419 *
     420 *      Taken from the OpenBSD sources at
     421 *
     422 +          ftp://ftp.openbsd.org/pub/OpenBSD/src/lib/libc/string/strlcpy.c
     423 *
     424 *      Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
     425 *      All rights reserved.
     426 *
     427 *      OpenBSD licence applies (see top of that file).
     428 *
     429 *@@added V1.0.1 (2003-01-29) [umoeller]
     430 */
     431
     432size_t strlcpy(char *dst,
     433               const char *src,
     434               size_t siz)
     435{
     436    register char       *d = dst;
     437    register const char *s = src;
     438    register size_t     n = siz;
     439
     440    /* Copy as many bytes as will fit */
     441    if (n != 0 && --n != 0)
     442    {
     443        do
     444        {
     445            if ((*d++ = *s++) == 0)
     446                break;
     447        } while (--n != 0);
     448    }
     449
     450    /* Not enough room in dst, add NUL and traverse rest of src */
     451    if (n == 0)
     452    {
     453        if (siz != 0)
     454            *d = '\0';      /* NUL-terminate dst */
     455        while (*s++)
     456            ;
     457    }
     458
     459    return (s - src - 1);    /* count does not include NUL */
     460}
     461
     462/*
     463 *@@ strlcat:
     464 *      appends src to string dst of size siz. Unlike strncat,
     465 *      siz is the full size of dst, not space left. At most
     466 *      siz-1 characters will be copied.  Always NUL terminates,
     467 *      unless siz <= strlen(dst).
     468 *
     469 *      Returns strlen(src) + MIN(siz, strlen(initial dst)),
     470 *      in other words, strlen(dst) after the concatenation.
     471 *      If retval >= siz, truncation occurred.
     472 *
     473 *      Taken from the OpenBSD sources at
     474 *
     475 +          ftp://ftp.openbsd.org/pub/OpenBSD/src/lib/libc/string/strlcat.c
     476 *
     477 *      Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
     478 *      All rights reserved.
     479 *
     480 *      OpenBSD licence applies (see top of that file).
     481 *
     482 *@@added V1.0.1 (2003-01-29) [umoeller]
     483 */
     484
     485size_t strlcat(char *dst,
     486               const char *src,
     487               size_t siz)
     488{
     489    register char       *d = dst;
     490    register const char *s = src;
     491    register size_t     n = siz;
     492    size_t              dlen;
     493
     494    /* Find the end of dst and adjust bytes left but don't go past end */
     495    while (n-- != 0 && *d != '\0')
     496        d++;
     497    dlen = d - dst;
     498    n = siz - dlen;
     499
     500    if (n == 0)
     501        return(dlen + strlen(s));
     502    while (*s != '\0')
     503    {
     504        if (n != 1)
     505        {
     506            *d++ = *s;
     507            n--;
     508        }
     509        s++;
     510    }
     511    *d = '\0';
     512
     513    return (dlen + (s - src));   /* count does not include NUL */
    411514}
    412515
     
    11601263
    11611264    return (pTarget - pszTarget);
     1265}
     1266
     1267/*
     1268 *@@ strhKillChar:
     1269 *      removes the first occurence of c in psz
     1270 *      by overwriting it with the following characters.
     1271 *
     1272 *      For this to work, you _must_ pass in strlen(psz)
     1273 *      in the ULONG pointed to by ulLength. If
     1274 *
     1275 *      Returns TRUE only if c was actually found. In
     1276 *      that case, *pulLength is decremented.
     1277 *
     1278 *@@added V1.0.1 (2003-01-30) [umoeller]
     1279 */
     1280
     1281BOOL strhKillChar(PSZ psz,
     1282                  CHAR c,
     1283                  PULONG pulLength)
     1284{
     1285    PSZ p;
     1286    if (p = strchr(psz, c))
     1287    {
     1288        // "string~rest"
     1289        //  ÀÄÄÄÄÄÙ 6 chars (p - pszBuf)
     1290        //  ÀÄÄÄÄÄÄÄÄÄÄÙ 11 chars (ulLen)
     1291        //        ^ p (pszBuf + 6)
     1292        //  ^ pszBuf
     1293        memmove(p,                      // pszBuf + 6
     1294                p + 1,                  // pszBuf + 7
     1295                // include null byte
     1296                  *pulLength            // 11
     1297                - (p - psz));           // - 6 = 5
     1298        --(*pulLength);
     1299
     1300        return TRUE;
     1301    }
     1302
     1303    return FALSE;
    11621304}
    11631305
     
    20322174          }
    20332175      }
     2176
    20342177    return NULL;                      //  Found nothing
    20352178}
    20362179
     2180
  • trunk/src/helpers/xstring.c

    r222 r245  
    11131113 *      especially with large string bufffers.
    11141114 *
    1115  *      None of the pointers can be NULL, but if pstrReplace
    1116  *      is empty, this effectively erases pstrSearch in pxstr.
     1115 *      pxstr and pstrReplace may not be NULL, but if
     1116 *      pstrReplace is null or empty, this effectively
     1117 *      erases pstrSearch in pxstr.
    11171118 *
    11181119 *      Returns the length of the new string (exclusing the
     
    11691170 *@@changed V0.9.6 (2000-11-12) [umoeller]: now using strhmemfind
    11701171 *@@changed V0.9.7 (2001-01-15) [umoeller]: renamed from xstrrpl; extracted new xstrrpl
     1172 *@@changed V1.0.1 (2003-02-02) [umoeller]: now allowing for NULL pstrReplace
    11711173 */
    11721174
     
    11751177                                                    // out: ofs of first char after replacement string
    11761178                      const XSTRING *pstrSearch,    // in: search string; cannot be NULL
    1177                       const XSTRING *pstrReplace,   // in: replacement string; cannot be NULL
     1179                      const XSTRING *pstrReplace,   // in: replacement string or NULL
    11781180                      size_t *pShiftTable,          // in: shift table (see strhmemfind)
    11791181                      PBOOL pfRepeatFind)           // in: repeat find? (see strhmemfind)
     
    11811183    ULONG    ulrc = 0;      // default: not found
    11821184
    1183     if ((pxstr) && (pstrSearch) && (pstrReplace))
     1185    if ((pxstr) && (pstrSearch))
    11841186    {
    11851187        ULONG   cSearchLen = pstrSearch->ulLength;
     
    12011203            {
    12021204                ULONG ulFirstReplOfs = pFound - pxstr->psz;
     1205                ULONG   lenRepl = pstrReplace ? (pstrReplace->ulLength) : 0;
    12031206                // found in buffer from ofs:
    12041207                // replace pFound with pstrReplace
     
    12061209                               ulFirstReplOfs,              // where to start
    12071210                               cSearchLen,                  // chars to replace
    1208                                pstrReplace->psz,
    1209                                pstrReplace->ulLength);      // adjusted V0.9.11 (2001-04-22) [umoeller]
     1211                               pstrReplace ? (pstrReplace->psz) : NULL,
     1212                               lenRepl);      // adjusted V0.9.11 (2001-04-22) [umoeller]
    12101213
    12111214                // return new length
    1212                 *pulOfs = ulFirstReplOfs + pstrReplace->ulLength;
     1215                *pulOfs = ulFirstReplOfs + lenRepl;
    12131216            } // end if (pFound)
    12141217        } // end if (    (*pulOfs < pxstr->ulLength) ...
Note: See TracChangeset for help on using the changeset viewer.