回复 7# CrLf
在有些可以找到的源代码中可以看到如下
cbatch.c 时间戳 1997-8-27- /*** eGenCmp - execute an if statement comparison - general case
- *
- * Purpose:
- * Return a nonzero value if comparison condition is met.
- * Otherwise return 0. This routine is never called unless
- * command extensions are enabled.
- *
- * int eStrCmp(struct cmdnode *n)
- *
- * Args:
- * n - the parse tree node containing the string comparison command
- *
- * Returns:
- * See above.
- *
- */
-
- int eGenCmp(n)
- struct cmdnode *n ;
- {
- TCHAR *s1, *s2;
- LONG n1, n2, iCompare;
-
- n1 = _tcstol(n->cmdline, &s1, 0);
- n2 = _tcstol(n->argptr, &s2, 0);
- if (*s1 == NULLC && *s2 == NULLC)
- iCompare = n1 - n2;
- else
- if (n->flag & CMDNODE_FLAG_IF_IGNCASE)
- iCompare = _tcsicmp(n->cmdline, n->argptr);
- else
- iCompare = _tcscmp(n->cmdline, n->argptr);
-
- switch (n->cmdarg) {
- case CMDNODE_ARG_IF_EQU:
- return iCompare == 0;
-
- case CMDNODE_ARG_IF_NEQ:
- return iCompare != 0;
-
- case CMDNODE_ARG_IF_LSS:
- return iCompare < 0;
-
- case CMDNODE_ARG_IF_LEQ:
- return iCompare <= 0;
-
- case CMDNODE_ARG_IF_GTR:
- return iCompare > 0;
-
- case CMDNODE_ARG_IF_GEQ:
- return iCompare >= 0;
- }
-
- return 0;
- }
复制代码 而对于 _tcscmp 和 _tcsicmp (前者分大小写, 后者忽略) 这两个函数
在 tchar.h 中有定义
http://research.microsoft.com/en ... include/tchar.h.htm
截取如下, 根据是否 UNICODE, 是 单字节字符集 还是 多字节字符集等判断, 出现三个实现分支.- #ifdef _UNICODE
- /* ++++++++++++++++++++ UNICODE ++++++++++++++++++++ */
- #define _tcscmp wcscmp
- #define _tcsicmp _wcsicmp
- #else /* _UNICODE */
- /* ++++++++++++++++++++ SBCS and MBCS ++++++++++++++++++++ */
- #ifdef _MBCS
- /* ++++++++++++++++++++ MBCS ++++++++++++++++++++ */
- #ifdef _MB_MAP_DIRECT
- /* use mb functions directly - types must match */
- #define _tcscmp _mbscmp
- #define _tcsicmp _mbsicmp
- #else /* _MB_MAP_DIRECT */
-
- #endif /* _MB_MAP_DIRECT */
- #else /* !_MBCS */
- /* ++++++++++++++++++++ SBCS ++++++++++++++++++++ */
- #define _tcscmp strcmp
- #define _tcsicmp _stricmp
- #endif /* _MBCS */
- #endif /* _UNICODE */
复制代码
|