ReactOS 0.4.15-dev-7958-gcd0bb1a
match.c File Reference
#include <schily/standard.h>
#include <schily/patmatch.h>
#include <schily/wchar.h>
#include <schily/wctype.h>
Include dependency graph for match.c:

Go to the source code of this file.

Classes

struct  args
 

Macros

#define POSIX_CLASS   /* Support [[:alpha:]] by default */
 
#define DID_UCHAR_TYPE
 
#define CHAR   Uchar
 
#define PCHAR   Uchar
 
#define ENDSTATE   (-1)
 
#define CL_SIZE   32 /* Max size for '[: :]' */
 
#define put(ret, state, sp, n)
 
#define CHK_POSIX_CLASS
 
#define in_class(found, pat, c)
 
#define rch(ap)
 
#define pch(ap)
 

Typedefs

typedef unsigned char Uchar
 
typedef struct args arg_t
 

Functions

EXPORT CHARopatmatch (PCHAR *pat, const int *aux, const CHAR *str, int soff, int slen, int alt) const
 
EXPORT CHARpatmatch (PCHAR *pat, const int *aux, const CHAR *str, int soff, int slen, int alt, state) const
 
LOCAL void nextitem __PR ((arg_t *))
 
LOCAL int expr __PR ((arg_t *, int *))
 
LOCAL void setexits __PR ((int *, int, int))
 
LOCAL void nextitem (arg_t *ap)
 
LOCAL int prim (arg_t *ap)
 
LOCAL int expr (arg_t *ap, int *altp)
 
LOCAL void setexits (int *aux, int list, int val)
 
LOCAL int join (int *aux, int a, int b)
 
EXPORT int patcompile (PCHAR *pat, int len, int *aux) const
 

Macro Definition Documentation

◆ CHAR

static CHAR   Uchar

Definition at line 83 of file match.c.

◆ CHK_POSIX_CLASS

#define CHK_POSIX_CLASS

Definition at line 132 of file match.c.

◆ CL_SIZE

#define CL_SIZE   32 /* Max size for '[: :]' */

Definition at line 95 of file match.c.

◆ DID_UCHAR_TYPE

#define DID_UCHAR_TYPE

Definition at line 82 of file match.c.

◆ ENDSTATE

#define ENDSTATE   (-1)

Definition at line 93 of file match.c.

◆ in_class

#define in_class (   found,
  pat,
  c 
)

Definition at line 168 of file match.c.

◆ pch

#define pch (   ap)
Value:
((((ap)->patp + 1) >= (ap)->length) ? \
0 \
: \
(ap)->pattern[(ap)->patp+1]) \
GLubyte * pattern
Definition: glext.h:7787
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
void int int ULONGLONG int va_list * ap
Definition: winesup.h:36

Definition at line 418 of file match.c.

◆ PCHAR

typedef PCHAR   Uchar

Definition at line 90 of file match.c.

Referenced by __RtlImageNtHeader(), _Requires_lock_held_(), _Success_(), AddGenericHeaderIPv4(), AhciAllocateResourceForAdapter(), AtapiInterrupt__(), AtapiSendCommand(), BaseCheckVDM(), BuildArgvForOsLoader(), CcCopyRead(), CcPinRead(), CcpMapData(), CdUpdateDirentName(), ClassDeviceHwFirmwareDownloadProcess(), ClassFindModePage(), ClasspIsMediaChangeDisabledDueToHardwareLimitation(), CmpCopyName(), CmpGetNameControlBlock(), co_IntCallHookProc(), CompareCharTable(), CON_API(), ConDrvReadInput(), ConDrvWriteOutput(), ConInString(), CopyBufferChainToBuffer(), CopyBufferToBufferChain(), CreateProcessInternalW(), CsrLoadServerDll(), DbgCommandString(), DbgPrompt(), DLDpFindCurrentThread(), Dns_PtrArrayToOffsetArray(), DosCopyEnvironmentBlock(), DosInt21h(), DosReadFile(), DumpTraceData(), EtfspCheckEtfs(), EtfspFileMatch(), EvalConvertParameterObjects(), EvalCreateParametersList(), ExpLoadInitialProcess(), Ext2IterateAllEa(), Ext2QueryEa(), Ext2SetEa(), ExtTextOutA(), FatPinEaRange(), FatSearchBufferForLabel(), FatSetFsLabelInfo(), FatSetRenameInfo(), FATXAddEntry(), FATXGetNextDirEntry(), FilterConnectCommunicationPort(), FindImportDescriptor(), FindMatchingCreateItem(), FixList(), FltGetVolumeProperties(), FltRegisterFilter(), FormatOutput(), FxPoolAllocator(), GetAnsiEnvironmentSize(), GetCurrentHwProfileA(), GetDIBPixel(), GetDmiString(), gethostbyname(), getsockopt(), GetSubkeyNames(), HalpAcpiGetTableFromBios(), HandleLoadUnloadIoctl(), Hostent_Init(), InfoTdiQueryGetInterfaceMIB(), IntMsgCreateStructW(), IntVideoPortGetMonitorDescription(), IntWideCharToMultiByteCP(), IoBuildPartialMdl(), IofCompleteRequest(), IopLogWorker(), IsBadReadPtr(), IsBadStringPtrA(), IsBadWritePtr(), IsValidPnpIdString(), KdbPrintStringWorker(), KdpCheckLowMemory(), KdpFillMemory(), KdpGetBusData(), KdpGetContext(), KdpGetContextEx(), KdpGetVersion(), KdpNotSupported(), KdpPrintString(), KdpPromptString(), KdpQueryMemory(), KdpReadControlSpace(), KdpReadIoSpace(), KdpReadIoSpaceExtended(), KdpReadMachineSpecificRegister(), KdpReadPhysicalMemory(), KdpReadVirtualMemory(), KdpReportCommandStringStateChange(), KdpReportExceptionStateChange(), KdpReportLoadSymbolsStateChange(), KdpRestoreBreakpoint(), KdpRestoreBreakPointEx(), KdpSearchMemory(), KdpSendWaitContinue(), KdpSetBusData(), KdpSetContext(), KdpSetContextEx(), KdpWriteBreakpoint(), KdpWriteBreakPointEx(), KdpWriteControlSpace(), KdpWriteCustomBreakpoint(), KdpWriteIoSpace(), KdpWriteIoSpaceExtended(), KdpWriteMachineSpecificRegister(), KdpWritePhysicalMemory(), KdpWriteVirtualMemory(), KdReceivePacket(), KeBugCheckWithTf(), KeGetBugMessageText(), KiInitMachineDependent(), LanEnumAdapters(), LauncherRoutine2(), LdrpCheckForKnownDll(), LdrpFetchAddressOfSecurityCookie(), main(), marshall_unicode_as_utf8(), MiBuildNonPagedPool(), MiQueryMemoryBasicInformation(), MiResolveImageReferences(), MiSnapThunk(), MmCreatePeb(), MsgiKMToUMMessage(), MyReallocPool__(), nfs41_ExtractNetRootName(), NmiClearFlag(), NSP_GetServiceByNameHeapAllocW(), NtfsReadFile(), NtGdiFlushUserBatch(), NtlmFixupAStr(), NtUserQueryWindow(), PackParam(), ParaNdis_PacketCopier(), ParseFonFile(), ParseSMBiosTables(), PciIdPrintfAppend(), PeLdrpBindImportName(), PrintDiskData(), ProbeMemory(), ProtocolTransferDataComplete(), Query_Main(), RamdiskGetPartitionInfo(), ReadVolumeLabel(), ReportDetectedPnpDevice(), RosSymCreateFromFile(), RosSymCreateFromMem(), RosSymCreateFromRaw(), RosSymGetAddressInformation(), RtlCompareMemoryUlong(), RtlCreateHeap(), RtlInitAnsiString(), RtlInitAnsiStringEx(), RtlIsDosDeviceName_Ustr(), RtlpCallQueryRegistryRoutine(), RtlReAllocateHeap(), RtlSplayTreeTest(), RtlUnicodeToCustomCPN(), RtlUpcaseUnicodeToCustomCPN(), SaBlob_CreateHostent(), SatisfyPreAccept(), ScrIoControl(), ScsiPortGetPhysicalAddress(), send(), CHttpClient::SendFile(), SendFragments(), sendto(), SkipToOffset(), SpiAdapterControl(), SpiParseDeviceInfo(), SURFACE_AllocSurface(), TextOutA(), UDFCommonDeviceControl(), UDFCompleteMount(), UDFPrepareForWriteOperation(), UniataEnumBusMasterController__(), UnpackHostEnt(), UnpackServEnt(), USBSTOR_HandleQueryProperty(), VfatReadDiskPartial(), vfatRenameEntry(), VfatWriteDiskPartial(), VfdDeviceControl(), VfdOpenImage(), VidBiosVideoService(), WCacheAllocAsyncEntry(), WCacheDirect__(), WCacheFlushBlocksRAM(), WCachePreReadPacket__(), WCacheReadBlocks__(), WCacheUpdatePacket(), WCacheWriteBlocks__(), WriteConsoleOutputCharacterA(), WriteConsoleOutputCharacterW(), WSAAsyncGetServByName(), and WSAAsyncGetServByPort().

◆ POSIX_CLASS

#define POSIX_CLASS   /* Support [[:alpha:]] by default */

Definition at line 4 of file match.c.

◆ put

#define put (   ret,
  state,
  sp,
  n 
)
Value:
{ \
register int *lstate = state; \
register int *lsp = sp; \
register int ln = n; \
\
while (lstate < lsp) { \
if (*lstate++ == ln) { \
ret = lsp; \
lsp = 0; \
break; \
} \
} \
if (lsp) { \
*lstate++ = ln; \
ret = lstate; \
} \
}
static int state
Definition: maze.c:121
GLdouble n
Definition: glext.h:7729
static const WCHAR sp[]
Definition: suminfo.c:287
int ret

Definition at line 105 of file match.c.

◆ rch

#define rch (   ap)
Value:
{ \
if (++(ap)->patp >= (ap)->length) \
(ap)->Ch = 0; \
else \
(ap)->Ch = (ap)->pattern[(ap)->patp]; \
}
#define Ch(x, y, z)
Definition: sha2.c:141

Definition at line 407 of file match.c.

Typedef Documentation

◆ arg_t

typedef struct args arg_t

◆ Uchar

typedef unsigned char Uchar

Definition at line 81 of file match.c.

Function Documentation

◆ __PR() [1/3]

LOCAL void nextitem __PR ( (arg_t *)  )

◆ __PR() [2/3]

LOCAL int expr __PR ( (arg_t *, int *)  )

◆ __PR() [3/3]

LOCAL void setexits __PR ( (int *, int, int )

◆ expr()

LOCAL int expr ( arg_t ap,
int altp 
)

Definition at line 512 of file match.c.

515{
516 int exits = ENDSTATE;
517 int a;
518 int *aux = ap->aux;
519 PCHAR Ch;
520
521 for (;;) {
522 a = prim(ap);
523 if (a == ENDSTATE)
524 return (ENDSTATE);
525 Ch = ap->Ch;
526 if (Ch == ALT || Ch == RBRACK || Ch == '\0') {
527 exits = join(aux, exits, a);
528 if (Ch != ALT)
529 return (exits);
530 *altp = ap->patp;
531 altp = &aux[ap->patp];
532 nextitem(ap);
533 } else
534 setexits(aux, a, ap->patp);
535 }
536}
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
#define a
Definition: ke_i.h:78
static const WCHAR aux[]
LOCAL int prim(arg_t *ap)
Definition: match.c:440
LOCAL void nextitem(arg_t *ap)
Definition: match.c:428
LOCAL int join(int *aux, int a, int b)
Definition: match.c:560
#define ENDSTATE
Definition: match.c:93
LOCAL void setexits(int *aux, int list, int val)
Definition: match.c:542
#define ALT
Definition: patmatch.h:51
#define RBRACK
Definition: patmatch.h:58
char * PCHAR
Definition: typedefs.h:51

◆ join()

LOCAL int join ( int aux,
int  a,
int  b 
)

Definition at line 560 of file match.c.

564{
565 int t;
566
567 if (a == ENDSTATE)
568 return (b);
569 t = a;
570 while (aux[t] != ENDSTATE)
571 t = aux[t];
572 aux[t] = b;
573 return (a);
574}
GLdouble GLdouble t
Definition: gl.h:2047
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define b
Definition: ke_i.h:79

Referenced by AddPenLinesBounds(), expr(), gdip_to_gdi_join(), GdipSetCustomLineCapStrokeJoin(), GdipSetPenLineJoin(), test_boundsrect(), test_create_adjustable_cap(), and test_linejoin().

◆ nextitem()

LOCAL void nextitem ( arg_t ap)

Definition at line 428 of file match.c.

430{
431 if (ap->Ch == QUOTE)
432 rch(ap);
433 rch(ap);
434}
#define QUOTE
Definition: kbdpo.c:220
#define rch(ap)
Definition: match.c:407

Referenced by enumvar_get_next_item(), expr(), and prim().

◆ opatmatch()

EXPORT CHAR * opatmatch ( PCHAR pat,
const int aux,
const CHAR str,
int  soff,
int  slen,
int  alt 
) const

Definition at line 209 of file match.c.

216{
217 int state[MAXPAT];
218
219 return (patmatch(pat, aux, str, soff, slen, alt, state));
220}
EXPORT CHAR * patmatch(PCHAR *pat, const int *aux, const CHAR *str, int soff, int slen, int alt, state) const
Definition: match.c:230
#define MAXPAT
Definition: patmatch.h:79
const WCHAR * str

◆ patcompile()

EXPORT int patcompile ( PCHAR pat,
int  len,
int aux 
) const

Definition at line 584 of file match.c.

588{
589 arg_t a;
590 int alt = ENDSTATE;
591 int i;
592
593 a.pattern = pat;
594 a.length = len;
595 a.aux = aux;
596 a.patp = -1;
597
598 for (i = 0; i < len; i++)
599 aux[i] = ENDSTATE;
600 rch(&a);
601 i = expr(&a, &alt);
602 if (i == ENDSTATE)
603 return (0);
605 return (alt);
606}
GLenum GLsizei len
Definition: glext.h:6722
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
Definition: match.c:390
Definition: query.h:87

Referenced by parse_errctl().

◆ patmatch()

EXPORT CHAR * patmatch ( PCHAR pat,
const int aux,
const CHAR str,
int  soff,
int  slen,
int  alt,
state   
) const

Definition at line 230 of file match.c.

238{
239 register int *sp;
240 register int *n;
241 register int *i;
242 register int p;
243 register int q, s, k;
244#ifdef __MB_CHAR
245 wchar_t c;
246 int mlen = 1;
247#else
248 int c;
249#endif
250 const CHAR *lastp = (CHAR *)NULL;
251
252#ifdef __LINE_MATCH
253for (; soff <= slen; soff++) {
254#endif
255
256 sp = state;
257 put(sp, state, state, 0);
258 if (alt != ENDSTATE)
259 put(sp, state, sp, alt);
260
261#ifdef __MB_CHAR
262 mbtowc(NULL, NULL, 0);
263 for (s = soff; ; s += mlen) {
264#else
265 for (s = soff; ; s++) {
266#endif
267 /*
268 * next char from input string
269 */
270 if (s >= slen) {
271 c = 0;
272 } else {
273#ifdef __MB_CHAR
274 mlen = mbtowc(&c, (char *)str, slen - s);
275 if (mlen < 0) {
276 mbtowc(NULL, NULL, 0);
277 c = str[s];
278 mlen = 1;
279 }
280#else
281 c = str[s];
282#endif
283 }
284 /*
285 * first complete the closure
286 */
287 for (n = state; n < sp; ) {
288 p = *n++; /* next state number */
289 if (p == ENDSTATE)
290 continue;
291 q = aux[p]; /* get next state for pat */
292 k = pat[p]; /* get next char from pat */
293 switch (k) {
294
295 case REP:
296 put(sp, state, sp, p+1);
297 /* FALLTHRU */
298 case NIL: /* NIL matches always */
299 case STAR:
300 put(sp, state, sp, q);
301 break;
302 case LBRACK: /* alternations */
303 case ALT:
304 put(sp, state, sp, p+1);
305 if (q != ENDSTATE)
306 put(sp, state, sp, q);
307 break;
308 case START:
309 if (s == 0)
310 put(sp, state, sp, q);
311 break;
312 case END:
313 if (c == '\0')
314 put(sp, state, sp, q);
315 break;
316 }
317 }
318
319 for (i = state; i < sp; ) {
320 if (*i++ == ENDSTATE) {
321 lastp = &str[s];
322 break;
323 }
324 }
325 if (c == 0)
326 return ((CHAR *)lastp);
327
328 /*
329 * now try to match next character
330 */
331 n = sp;
332 sp = state;
333 for (i = sp; i < n; ) {
334 p = *i++; /* next active state number */
335 if (p == ENDSTATE)
336 continue;
337 k = pat[p];
338 switch (k) {
339
340 case ALT:
341 case REP:
342 case NIL:
343 case LBRACK:
344 case START:
345 case END:
346 continue;
347 case LCLASS:
348 in_class(q, &pat[p+1], c);
349 if (!q)
350 continue;
351 break;
352 case STAR:
353 put(sp, state, sp, p);
354 continue;
355 case QUOTE:
356 k = pat[p+1];
357 default:
358 if (k != c)
359 continue;
360 /* FALLTHRU */
361 case ANY:
362 break;
363 }
364 put(sp, state, sp, aux[p]);
365 }
366 if (sp == state) { /* if no new states return */
367#ifdef __LINE_MATCH
368
369 if (lastp || (soff == slen - 1))
370 return ((CHAR *)lastp);
371 else
372 break;
373#else
374 return ((CHAR *)lastp);
375#endif
376 }
377 }
378#ifdef __LINE_MATCH
379}
380return ((CHAR *)lastp);
381#endif
382}
#define NULL
Definition: types.h:112
GLdouble s
Definition: gl.h:2039
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
const GLubyte * c
Definition: glext.h:8905
GLfloat GLfloat p
Definition: glext.h:8902
#define c
Definition: ke_i.h:80
#define put(ret, state, sp, n)
Definition: match.c:105
#define in_class(found, pat, c)
Definition: match.c:168
#define END
Definition: options.h:105
int k
Definition: mpi.c:3369
#define LBRACK
Definition: patmatch.h:57
#define START
Definition: patmatch.h:63
#define REP
Definition: patmatch.h:52
#define ANY
Definition: patmatch.h:55
#define LCLASS
Definition: patmatch.h:59
#define STAR
Definition: patmatch.h:54
#define mbtowc(wp, cp, len)
Definition: wchar.h:155
#define NIL
Definition: trio.c:106
char CHAR
Definition: xmlstorage.h:175

Referenced by _errptr(), and opatmatch().

◆ prim()

LOCAL int prim ( arg_t ap)

Definition at line 440 of file match.c.

442{
443 int a = ap->patp;
444 int op = ap->Ch;
445 int t;
446
447 nextitem(ap);
448 switch (op) {
449
450 case '\0':
451 case ALT:
452 case RBRACK:
453 return (ENDSTATE);
454 case LCLASS:
455 while (ap->Ch != RCLASS && ap->Ch != '\0') {
456#ifdef POSIX_CLASS
457 if (ap->Ch == LCLASS) {
458 if (pch(ap) == ':') { /* [:alpha:] */
459 char class[CL_SIZE+1];
460 char *pc = class;
461
462 nextitem(ap);
463 nextitem(ap);
464 while (ap->Ch != ':' &&
465 ap->Ch != '\0') {
466 if (pc > &class[CL_SIZE])
467 return (ENDSTATE);
468 *pc = ap->Ch;
469 if (*pc++ != ap->Ch)
470 return (ENDSTATE);
471 nextitem(ap);
472 }
473 if (pc == class)
474 return (ENDSTATE);
475 *pc = '\0';
476 if (ap->Ch == '\0')
477 return (ENDSTATE);
478 if (wctype(class) == 0)
479 return (ENDSTATE);
480 nextitem(ap);
481 }
482 if (ap->Ch != RCLASS)
483 return (ENDSTATE);
484 }
485#endif
486 nextitem(ap);
487 }
488 if (ap->Ch == '\0')
489 return (ENDSTATE);
490 nextitem(ap);
491 break;
492 case REP:
493 t = prim(ap);
494 if (t == ENDSTATE)
495 return (ENDSTATE);
496 setexits(ap->aux, t, a);
497 break;
498 case LBRACK:
499 a = expr(ap, &ap->aux[a]);
500 if (a == ENDSTATE || ap->Ch != RBRACK)
501 return (ENDSTATE);
502 nextitem(ap);
503 break;
504 }
505 return (a);
506}
UINT op
Definition: effect.c:236
wctype_t __cdecl wctype(const char *)
#define pch(ap)
Definition: match.c:418
#define CL_SIZE
Definition: match.c:95
#define RCLASS
Definition: patmatch.h:60

Referenced by DateConstr_value(), equal_values(), expr(), gl_EvalMesh1(), prim(), to_number(), to_primitive(), and to_string().

◆ setexits()

LOCAL void setexits ( int aux,
int  list,
int  val 
)

Definition at line 542 of file match.c.

546{
547 int a;
548
549 while (list != ENDSTATE) {
550 a = aux[list];
551 aux[list] = val;
552 list = a;
553 }
554}
Definition: list.h:37
GLuint GLfloat * val
Definition: glext.h:7180
#define list
Definition: rosglue.h:35

Referenced by expr(), patcompile(), and prim().