core: import NSS Unicode string helpers into libnwcore

This commit is contained in:
OpenAI
2026-06-12 14:31:48 +00:00
committed by Mario Fetka
parent fc26af21dc
commit b7bd99a2ed
14 changed files with 557 additions and 5 deletions

27
AI.md
View File

@@ -1,9 +1,9 @@
# AI working notes for mars-nwe
## Current handoff status after NSS low-level imports 0404-0410
## Current handoff status after NSS low-level imports 0404-0412
Current accepted MARS-NWE server line in this work session includes the NSS
low-level libnwcore imports through `0410`:
low-level libnwcore imports through `0412`:
- `0404` imports NSS `bitmap.c` directly as `src/core/bitmap.c`.
- `0405` moves the imported bitmap/NSS base headers directly into
@@ -21,9 +21,18 @@ low-level libnwcore imports through `0410`:
- `0410` imports NSS `xUnicode.h`, `unitolower.c`, and `utf_tolower.c` directly
into libnwcore and removes the private `crc.c` lowercase fallback. The
exported `NSSUniToLower[]` table is now present in libnwcore with the same
ASCII-compatible initialization as the old fallback; the full NSS Unicode
converter/table startup from `public_core/library/unicode/unicodeInit.c` is
still a separate follow-up because it pulls in the NetWare/libc converter
ASCII-compatible initialization as the old fallback.
- `0411` extends the direct NSS Unicode helper import with `unitoupper.c`,
`unilwr.c`, `uniupr.c`, `uniicmp.c`, `uniicmpmac.c`, and `uninicmp.c` in
libnwcore; `unicodeInit.c` now exports both `NSSUniToLower[]` and
`NSSUniToUpper[]` with the same ASCII-compatible bootstrap.
- `0412` imports the NSS Unicode string helper block into libnwcore:
`componentUnicpy.c`, `componentUnilen.c`, `unicat.c`, `unicmp.c`, `unicpy.c`,
`unilen.c`, and `unimcpy.c`, with their matching sharedsrc implementation
headers kept local to `src/core/`. This keeps the original NSS `LB_*` API
names available before replacing older MARS Unicode/string helpers. The full
NSS Unicode converter/table startup from `public_core/library/unicode/unicodeInit.c`
is still a separate follow-up because it pulls in the NetWare/libc converter
runtime.
Keep future NSS low-level imports directly under `src/core/<original>.c` and
@@ -2444,3 +2453,11 @@ logs/archives are usually copied or uploaded later by a normal desktop user.
`libnwcore`; `unicodeInit.c` now exports both `NSSUniToLower[]` and
`NSSUniToUpper[]` with the same ASCII-compatible bootstrap until the full NSS
converter/table startup is imported.
- `0412` imports the next safe NSS Unicode library block into `libnwcore`: the
component/string helpers `componentUnicpy.c`, `componentUnilen.c`, `unicat.c`,
`unicmp.c`, `unicpy.c`, `unilen.c`, and `unimcpy.c`. Their sharedsrc
implementation headers (`*.c.h`) are kept local under `src/core/` and are not
installed as public API. No MARS callsites are switched yet; this is a
prerequisite for replacing the older hand-written MARS Unicode/string code
piece by piece with NSS-compatible primitives.

View File

@@ -85,6 +85,13 @@ set(NWCORE_IMPORTED_NSS_SOURCES
bit.c
crc.c
hash.c
componentUnicpy.c
componentUnilen.c
unicat.c
unicmp.c
unicpy.c
unilen.c
unimcpy.c
unicodeInit.c
unitolower.c
unitoupper.c

View File

@@ -0,0 +1,59 @@
/****************************************************************************
|
| (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc.
| All Rights Reserved.
|
| This program is free software; you can redistribute it and/or
| modify it under the terms of version 2 of the GNU General Public
| License as published by the Free Software Foundation.
|
| 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, contact Novell, Inc.
|
| To contact Novell about this file by physical or electronic mail,
| you may find current contact information at www.novell.com
|
|***************************************************************************
|
| NetWare Advance File Services (NSS) module
|
|---------------------------------------------------------------------------
|
| $Author: taysom $
| $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $
|
| $RCSfile$
| $Revision: 465 $
|
|---------------------------------------------------------------------------
| This module is used to:
| NSS Library Routine
+-------------------------------------------------------------------------*/
#include <xUnicode.h>
/**************************************************************************
* Copy string s2 to s1. s1 must be large enough.
* return s1
***************************************************************************/
unicode_t *LB_componentUnicpy(
unicode_t *dest,
CONST unicode_t *src)
{
unicode_t *odest = dest;
/* Copy all components until a NULL component is encountered */
while (*src)
{
/* Copy next individual component, including it's NULL */
while( (*dest++ = *src++) != (unicode_t)0 )
;
}
*dest = 0;
return(odest);
}

View File

@@ -0,0 +1,56 @@
/****************************************************************************
|
| (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc.
| All Rights Reserved.
|
| This program is free software; you can redistribute it and/or
| modify it under the terms of version 2 of the GNU General Public
| License as published by the Free Software Foundation.
|
| 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, contact Novell, Inc.
|
| To contact Novell about this file by physical or electronic mail,
| you may find current contact information at www.novell.com
|
|***************************************************************************
|
| NetWare Advance File Services (NSS) module
|
|---------------------------------------------------------------------------
|
| $Author: taysom $
| $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $
|
| $RCSfile$
| $Revision: 465 $
|
|---------------------------------------------------------------------------
| This module is used to:
| This is a temporary routine to emulate what the real unicode_t
| routines will do.
+-------------------------------------------------------------------------*/
#include <xUnicode.h>
/**************************************************************************
* Returns the number of characters in the string
***************************************************************************/
size_t LB_componentUnilen(
CONST unicode_t *s)
{
size_t size;
size_t totalSize = 0;
while (*s)
{
size = unilen(s);
totalSize += (size+1);
s += (size+1);
}
return(totalSize);
}

1
src/core/unicat.c Normal file
View File

@@ -0,0 +1 @@
#include "unicat.c.h"

87
src/core/unicat.c.h Normal file
View File

@@ -0,0 +1,87 @@
/****************************************************************************
|
| (C) Copyright 1999, 2003 Novell, Inc.
| All Rights Reserved.
|
| This program is free software; you can redistribute it and/or
| modify it under the terms of version 2 of the GNU General Public
| License as published by the Free Software Foundation.
|
| 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, contact Novell, Inc.
|
| To contact Novell about this file by physical or electronic mail,
| you may find current contact information at www.novell.com
|
|***************************************************************************
|
| NetWare Advance File Services (NSS) module
|
|---------------------------------------------------------------------------
|
| $Author: stoner $
| $Date: 2005-04-05 22:42:53 +0530 (Tue, 05 Apr 2005) $
|
| $RCSfile$
| $Revision: 905 $
|
|---------------------------------------------------------------------------
| This module is used to:
| NSS Library Routine code taken from LibC in August 2003
+-------------------------------------------------------------------------*/
#include <xUnicode.h>
unicode_t *LB_unicat
(
register unicode_t *t,
register const unicode_t *s
)
{
unicode_t *base = t;
while (*t++)
;
t--;
while ( (*t++ = *s++) != (unicode_t)0 )
;
return base;
}
unicode_t *LB_unincat
(
register unicode_t *t,
register const unicode_t *s,
register size_t n
)
{
unicode_t *base = t;
if (n > 0)
{
n++;
while (*t++)
;
t--;
while ( (*t++ = *s++) != (unicode_t)0 )
{
if (--n == 0)
{
*(t - 1) = 0x0000;
break;
}
}
}
return base;
}

1
src/core/unicmp.c Normal file
View File

@@ -0,0 +1 @@
#include "unicmp.c.h"

75
src/core/unicmp.c.h Normal file
View File

@@ -0,0 +1,75 @@
/****************************************************************************
|
| (C) Copyright 1999, 2003 Novell, Inc.
| All Rights Reserved.
|
| This program is free software; you can redistribute it and/or
| modify it under the terms of version 2 of the GNU General Public
| License as published by the Free Software Foundation.
|
| 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, contact Novell, Inc.
|
| To contact Novell about this file by physical or electronic mail,
| you may find current contact information at www.novell.com
|
|***************************************************************************
|
| NetWare Advance File Services (NSS) module
|
|---------------------------------------------------------------------------
|
| $Author: taysom $
| $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $
|
| $RCSfile$
| $Revision: 465 $
|
|---------------------------------------------------------------------------
| This module is used to:
| NSS Library Routine code taken from LibC in August 2003
+-------------------------------------------------------------------------*/
#include <xUnicode.h>
int LB_unicmp
(
const unicode_t *s1,
const unicode_t *s2
)
{
while (*s1 == *s2 && *s1)
{
s1++;
s2++;
}
return (*s1 - *s2);
}
int LB_unincmp
(
register const unicode_t *s1,
register const unicode_t *s2,
register size_t n
)
{
n++;
if (s1 == s2)
return 0;
while (--n != 0 && *s1 == *s2)
{
if (!*s1)
return 0;
s1++; s2++;
}
return ((n == 0) ? 0 : (*s1 - *s2));
}

1
src/core/unicpy.c Normal file
View File

@@ -0,0 +1 @@
#include "unicpy.c.h"

123
src/core/unicpy.c.h Normal file
View File

@@ -0,0 +1,123 @@
/****************************************************************************
|
| (C) Copyright 1985, 1991, 1993, 1996, 1999, 2003 Novell, Inc.
| All Rights Reserved.
|
| This program is free software; you can redistribute it and/or
| modify it under the terms of version 2 of the GNU General Public
| License as published by the Free Software Foundation.
|
| 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, contact Novell, Inc.
|
| To contact Novell about this file by physical or electronic mail,
| you may find current contact information at www.novell.com
|
|***************************************************************************
|
| NetWare Advance File Services (NSS) module
|
|---------------------------------------------------------------------------
|
| $Author: taysom $
| $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $
|
| $RCSfile$
| $Revision: 465 $
|
|---------------------------------------------------------------------------
| This module is used to:
| NSS Library Routine
+-------------------------------------------------------------------------*/
#include <xUnicode.h>
/**************************************************************************
* Copy string s2 to s1. s1 must be large enough.
* return s1
***************************************************************************/
unicode_t *LB_unicpy(
unicode_t *dest,
const unicode_t *src)
{
unicode_t *odest = dest;
while( (*dest++ = *src++) != (unicode_t)0 )
;
return(odest);
}
/* From LibC Sources */
unicode_t *LB_unincpy
(
register unicode_t *t,
register const unicode_t *s,
register size_t n
)
{
register unicode_t *base = t;
n++;
while (--n > 0 && (*t++ = *s++))
;
if (n > 0)
{
while (--n > 0)
*t++ = 0x0000;
}
return base;
}
/* From LibC Sources */
unicode_t *LB_unichr
(
register const unicode_t *sp,
register unicode_t ch
)
{
/*
** Return the point in 'sp' at which the character ch appears or nil if
** not found.
*/
do
{
if (*sp == ch)
return (unicode_t *) sp;
}
while (*sp++);
return (unicode_t *) NULL;
}
/* From LibC Sources */
unicode_t *LB_unirchr
(
register const unicode_t *sp,
register unicode_t ch
)
{
register const unicode_t *r = (const unicode_t *) NULL;
/*
** Return the ptr in sp at which the character ch last appears; NULL if
** not found.
*/
do
{
if (*sp == ch)
r = sp;
}
while (*sp++);
return (unicode_t *) r;
}

1
src/core/unilen.c Normal file
View File

@@ -0,0 +1 @@
#include "unilen.c.h"

58
src/core/unilen.c.h Normal file
View File

@@ -0,0 +1,58 @@
/****************************************************************************
|
| (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc.
| All Rights Reserved.
|
| This program is free software; you can redistribute it and/or
| modify it under the terms of version 2 of the GNU General Public
| License as published by the Free Software Foundation.
|
| 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, contact Novell, Inc.
|
| To contact Novell about this file by physical or electronic mail,
| you may find current contact information at www.novell.com
|
|***************************************************************************
|
| NetWare Advance File Services (NSS) module
|
|---------------------------------------------------------------------------
|
| $Author: stoner $
| $Date: 2005-04-05 22:42:53 +0530 (Tue, 05 Apr 2005) $
|
| $RCSfile$
| $Revision: 905 $
|
|---------------------------------------------------------------------------
| This module is used to:
| This is a temporary routine to emulate what the real unicode_t
| routines will do.
+-------------------------------------------------------------------------*/
#include <xUnicode.h>
#if defined(_WATCOMC_)
#include <inlines.h>
#endif
/**************************************************************************
* Returns the number of characters in the string
***************************************************************************/
size_t LB_unilen(
const unicode_t *s)
{
#if !defined(_WATCOMC_)
const unicode_t *s0 = s;
while (*s != 0)
s++;
return (s - s0);
#else
return inline_unilen(s);
#endif
}

1
src/core/unimcpy.c Normal file
View File

@@ -0,0 +1 @@
#include "unimcpy.c.h"

65
src/core/unimcpy.c.h Normal file
View File

@@ -0,0 +1,65 @@
/****************************************************************************
|
| (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc.
| All Rights Reserved.
|
| This program is free software; you can redistribute it and/or
| modify it under the terms of version 2 of the GNU General Public
| License as published by the Free Software Foundation.
|
| 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, contact Novell, Inc.
|
| To contact Novell about this file by physical or electronic mail,
| you may find current contact information at www.novell.com
|
|***************************************************************************
|
| NetWare Advance File Services (NSS) module
|
|---------------------------------------------------------------------------
|
| $Author: taysom $
| $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $
|
| $RCSfile$
| $Revision: 465 $
|
|---------------------------------------------------------------------------
| This module is used to:
| This is a temporary routine to emulate what the real unicode_t
| routines will do.
+-------------------------------------------------------------------------*/
#include <xUnicode.h>
/**************************************************************************
* This will copy the source string to the destination string and will
* not overflow the destination buffer. This will guarentee there is a
* null at the end of the destination string. This returns a pointer to
* the front of the destination string.
***************************************************************************/
unicode_t *LB_unimcpy(
unicode_t *dest,
CONST unicode_t *src,
size_t destSize) /* sizeof the destination buffer in UNICODE chars*/
{
unicode_t *ldest = dest;
if (destSize == 0)
{
return(dest);
}
for (;;) {
if (--destSize <= 0) {
*ldest = 0;
break;
}
if ((*ldest++ = (unicode_t)*src++) == 0)
break;
}
return dest;
}