From 87a491d7b64f34a9692af3edc58151e9baa2e275 Mon Sep 17 00:00:00 2001 From: Hartmut Holzgraefe Date: Fri, 16 Jun 2000 18:24:02 +0000 Subject: [PATCH] C++ // comments are evil ... --- ext/cpdf/cpdf.c | 2 +- ext/dav/dav.c | 2 + ext/domxml/php_domxml.c | 24 ++--- ext/hyperwave/hw.c | 14 +-- ext/hyperwave/php_hyperwave.h | 2 +- ext/icap/php_icap.c | 6 +- ext/imap/php_imap.c | 3 + ext/msql/php_msql.c | 4 +- ext/mysql/libmysql/config-win32.h | 2 +- ext/mysql/libmysql/my_pthread.h | 6 +- ext/rpc/com/COM.c | 16 +-- ext/snmp/winsnmp.c | 2 +- ext/standard/info.c | 4 +- ext/standard/levenshtein.c | 162 +++++++++++++++++++++++++++--- ext/yaz/php_yaz.c | 2 +- ext/zlib/zlib.c | 14 +-- sapi/isapi/php4isapi.c | 6 +- win32/sendmail.c | 103 ++++++++++--------- win32/sendmail.h | 8 +- win32/syslog.h | 4 +- win32/winutil.c | 2 +- 21 files changed, 269 insertions(+), 119 deletions(-) diff --git a/ext/cpdf/cpdf.c b/ext/cpdf/cpdf.c index 2371d57cd03..ed12dd7cb17 100644 --- a/ext/cpdf/cpdf.c +++ b/ext/cpdf/cpdf.c @@ -360,7 +360,7 @@ PHP_FUNCTION(cpdf_set_viewer_preferences) { RETURN_FALSE; } -// cpdf_setViewerPreferences(pdf, pagemode, 0, 0, 0, 0, 0, 0, pagemode); +/* cpdf_setViewerPreferences(pdf, pagemode, 0, 0, 0, 0, 0, 0, pagemode); */ RETURN_TRUE; } diff --git a/ext/dav/dav.c b/ext/dav/dav.c index 31208a7b46d..17c0a6ad258 100644 --- a/ext/dav/dav.c +++ b/ext/dav/dav.c @@ -35,6 +35,8 @@ #if HAVE_MOD_DAV +#error The DAV support in PHP needs to be completely rewritten. Everything has changed + # include "mod_dav.h" #include "ext/standard/info.h" diff --git a/ext/domxml/php_domxml.c b/ext/domxml/php_domxml.c index 090907a855b..94c9f4503cf 100644 --- a/ext/domxml/php_domxml.c +++ b/ext/domxml/php_domxml.c @@ -24,7 +24,7 @@ #if HAVE_DOMXML #include "ext/standard/info.h" -//#define newcode +/*#define newcode*/ static int le_domxmldocp; static int le_domxmldtdp; @@ -108,7 +108,7 @@ zend_module_entry php_domxml_module_entry = { }; void _free_node(xmlNode *tmp) { -//fprintf(stderr, "Freeing node: %s\n", tmp->name); +/*fprintf(stderr, "Freeing node: %s\n", tmp->name);*/ } PHP_MINIT_FUNCTION(domxml) @@ -129,7 +129,7 @@ PHP_MINIT_FUNCTION(domxml) */ le_domxmlnodep = register_list_destructors(_free_node, NULL); le_domxmlattrp = register_list_destructors(NULL, NULL); -// le_domxmlnsp = register_list_destructors(NULL, NULL); +/* le_domxmlnsp = register_list_destructors(NULL, NULL); */ INIT_CLASS_ENTRY(domxmldoc_class_entry, "DomDocument", php_domxmldoc_class_functions); INIT_CLASS_ENTRY(domxmldtd_class_entry, "Dtd", php_domxmldtd_class_functions); @@ -320,7 +320,7 @@ PHP_MINFO_FUNCTION(domxml) /* don't know why that line was commented out in the previous version, so i left it (cmv) */ php_info_print_table_start(); php_info_print_table_row(2, "DOM/XML Support", "enabled"); -// php_info_print_table_row(2, "libmxl Version", LIBXML_VERSION ); +/* php_info_print_table_row(2, "libmxl Version", LIBXML_VERSION ); */ php_info_print_table_end(); } @@ -376,7 +376,7 @@ PHP_FUNCTION(domxml_attrname) object_init_ex(pattr, domxmlattr_class_entry_ptr); add_property_resource(pattr, "attribute", ret); add_property_stringl(pattr, "name", (char *) attr->name, strlen(attr->name), 1); -// add_property_stringl(pattr, "content", (char *) attr->val->content, strlen(attr->val->content), 1); +/* add_property_stringl(pattr, "content", (char *) attr->val->content, strlen(attr->val->content), 1); */ zend_hash_next_index_insert(return_value->value.ht, &pattr, sizeof(zval *), NULL); attr = attr->next; } @@ -918,7 +918,7 @@ PHP_FUNCTION(domxml_dumpmem) zval *id, **tmp; int id_to_find; xmlDoc *docp; -// char *mem; +/* char *mem; */ xmlChar *mem; int size; int type; @@ -1181,11 +1181,11 @@ static int node_namespace(zval **attributes, xmlNode *nodep) while(ns) { zval *pattr; MAKE_STD_ZVAL(pattr); -// ret = zend_list_insert(attr, le_domxmlattrp); +/* ret = zend_list_insert(attr, le_domxmlattrp); */ /* construct an object with some methods */ object_init_ex(pattr, domxmlns_class_entry_ptr); -// add_property_resource(pattr, "attribute", ret); +/* add_property_resource(pattr, "attribute", ret); */ if(ns->href) add_property_stringl(pattr, "href", (char *) ns->href, strlen(ns->href), 1); if(ns->prefix) @@ -1214,7 +1214,7 @@ static int node_attributes(zval **attributes, xmlNode *nodep) } /* create an php array for the children */ -// MAKE_STD_ZVAL(*attributes); // Don't do this if *attributes are the return_value +/* MAKE_STD_ZVAL(*attributes); *//* Don't do this if *attributes are the return_value */ if (array_init(*attributes) == FAILURE) { return -1; } @@ -1262,7 +1262,7 @@ static int node_children(zval **children, xmlNode *nodep) /* Each child is a node object */ MAKE_STD_ZVAL(child); -// ret = zend_list_insert(last, le_domxmlnodep); +/* ret = zend_list_insert(last, le_domxmlnodep); */ /* construct a node object for each child */ object_init_ex(child, domxmlnode_class_entry_ptr); @@ -1275,7 +1275,7 @@ static int node_children(zval **children, xmlNode *nodep) add_property_long(child, "type", last->type); if(last->content) add_property_stringl(child, "content", (char *) last->content, strlen(last->content), 1); -// add_property_resource(child, "node", ret); +/* add_property_resource(child, "node", ret); */ /* Get the namespace of the current node and add it as a property */ /* if(!node_namespace(&namespace, last)) @@ -1283,7 +1283,7 @@ static int node_children(zval **children, xmlNode *nodep) */ /* Get the attributes of the current node and add it as a property */ - MAKE_STD_ZVAL(attributes); // Because it was taken out of node_attributes() + MAKE_STD_ZVAL(attributes); /* Because it was taken out of node_attributes() */ if(0 <= node_attributes(&attributes, last)) zend_hash_update(child->value.obj.properties, "attributes", sizeof("attributes"), (void *) &attributes, sizeof(zval *), NULL); diff --git a/ext/hyperwave/hw.c b/ext/hyperwave/hw.c index 254aaa80d6d..f1af66a918e 100644 --- a/ext/hyperwave/hw.c +++ b/ext/hyperwave/hw.c @@ -42,7 +42,7 @@ #include "php_ini.h" #include "php_hyperwave.h" -//hw_module php_hw_module; +/*hw_module php_hw_module;*/ #define HW_ATTR_NONE 1 #define HW_ATTR_LANG 2 @@ -375,9 +375,11 @@ int make2_return_array_from_objrec(pval **return_value, char *objrec, zval *sarr attrname = php_strtok_r(NULL, "\n", &strtok_buf); } if(NULL == sarr){ -// spec_arr->refcount--; -// zend_hash_destroy(spec_arr->value.ht); -// efree(spec_arr->value.ht); +/* + spec_arr->refcount--; + zend_hash_destroy(spec_arr->value.ht); + efree(spec_arr->value.ht); +*/ zval_dtor(spec_arr); efree(spec_arr); } @@ -546,7 +548,7 @@ static char * make_objrec_from_array(HashTable *lht) { *objrec = '\0'; for(i=0; itype) { @@ -598,7 +600,7 @@ static char * make_objrec_from_array(HashTable *lht) { if(HASH_KEY_IS_STRING == keytype) efree(key); objrec = realloc(objrec, strlen(objrec)+strlen(str)+1); strcat(objrec, str); -// } +/* } */ zend_hash_move_forward(lht); } return objrec; diff --git a/ext/hyperwave/php_hyperwave.h b/ext/hyperwave/php_hyperwave.h index 067162bd83b..bb67d3d28bc 100644 --- a/ext/hyperwave/php_hyperwave.h +++ b/ext/hyperwave/php_hyperwave.h @@ -74,7 +74,7 @@ typedef struct { extern PHP_HW_API php_hw_globals hw_globals; #endif -//extern hw_module php_hw_module; +/*extern hw_module php_hw_module;*/ typedef struct { int size; diff --git a/ext/icap/php_icap.c b/ext/icap/php_icap.c index 66d0e602488..86dbc76b6ca 100644 --- a/ext/icap/php_icap.c +++ b/ext/icap/php_icap.c @@ -272,8 +272,10 @@ PHP_FUNCTION(icap_reopen) flags = options->value.lval; icap_le_struct->flags = cl_flags; } - // icap_stream = cal_connect(calendar->value.str.val); - // cal_login(icap_stream, calendar->value.str.val); + /* + icap_stream = cal_connect(calendar->value.str.val); + cal_login(icap_stream, calendar->value.str.val); + */ if (icap_stream == NULL) { php_error(E_WARNING,"Couldn't re-open stream\n"); RETURN_FALSE; diff --git a/ext/imap/php_imap.c b/ext/imap/php_imap.c index 170d9ed3632..120779f150f 100644 --- a/ext/imap/php_imap.c +++ b/ext/imap/php_imap.c @@ -20,6 +20,7 @@ | Rasmus Lerdorf | | Chuck Hagenbuch | | Andrew Skalski | + | Hartmut Holzgraefe | | PHP 4.0 updates: Zeev Suraski | +----------------------------------------------------------------------+ */ @@ -1026,6 +1027,8 @@ PHP_FUNCTION(imap_close) } imap_le_struct->flags = flags; } + mail_close_it(imap_le_struct); + zend_list_delete(ind); RETURN_TRUE; } diff --git a/ext/msql/php_msql.c b/ext/msql/php_msql.c index 0ddbfd7229e..0228b7eb0ca 100644 --- a/ext/msql/php_msql.c +++ b/ext/msql/php_msql.c @@ -944,7 +944,9 @@ static void php_msql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type) add_assoc_stringl(return_value, msql_field->name, data, data_len, should_copy); } } else { - //add_get_index_stringl(return_value, i, empty_string, 0, (void **) &pval_ptr, 1); + /* + add_get_index_stringl(return_value, i, empty_string, 0, (void **) &pval_ptr, 1); + */ } } } diff --git a/ext/mysql/libmysql/config-win32.h b/ext/mysql/libmysql/config-win32.h index 3962ebbd0bd..e8335739cc1 100644 --- a/ext/mysql/libmysql/config-win32.h +++ b/ext/mysql/libmysql/config-win32.h @@ -206,7 +206,7 @@ inline double ulonglong2double(ulonglong value) #define HAVE_ALLOCA #define HAVE_STRPBRK #define HAVE_STRSTR -//#define HAVE_COMPRESS +/*#define HAVE_COMPRESS*/ #ifdef _MSC_VER #define HAVE_LDIV /* The optimizer breaks in zortech for ldiv */ diff --git a/ext/mysql/libmysql/my_pthread.h b/ext/mysql/libmysql/my_pthread.h index 47a058a65cc..ad64c59a50c 100644 --- a/ext/mysql/libmysql/my_pthread.h +++ b/ext/mysql/libmysql/my_pthread.h @@ -8,7 +8,7 @@ #include #ifndef ETIME -#define ETIME ETIMEDOUT // For FreeBSD +#define ETIME ETIMEDOUT /* For FreeBSD */ #endif #if defined(__WIN32__) @@ -102,8 +102,8 @@ void pthread_exit(unsigned A); /* was #define pthread_exit(A) ExitThread(A)*/ #define pthread_condattr_init(A) #define pthread_condattr_destroy(A) -//Irena: compiler does not like this: -//#define my_pthread_getprio(pthread_t thread_id) pthread_dummy(0) +/*Irena: compiler does not like this:*/ +/*#define my_pthread_getprio(pthread_t thread_id) pthread_dummy(0)*/ #define my_pthread_getprio(thread_id) pthread_dummy(0) #elif defined(HAVE_UNIXWARE7_THREADS) diff --git a/ext/rpc/com/COM.c b/ext/rpc/com/COM.c index 28d8b488175..4a04547b1bb 100644 --- a/ext/rpc/com/COM.c +++ b/ext/rpc/com/COM.c @@ -135,7 +135,7 @@ static char *php_string_from_clsid(CLSID *clsid) char *clsid_str; StringFromCLSID(clsid, &ole_clsid); - //s_clsid = OLE2A(ole_clsid); + /*s_clsid = OLE2A(ole_clsid);*/ clsid_str = php_OLECHAR_to_char(ole_clsid, NULL, 0); LocalFree(ole_clsid); @@ -270,7 +270,7 @@ PHP_FUNCTION(COM_load) hr=CLSIDFromProgID(ProgID, &clsid); efree(ProgID); - // obtain CLSID + /* obtain CLSID */ if (FAILED(hr)) { error_message = php_COM_error_message(hr); php_error(E_WARNING,"Invalid ProgID: %s\n", error_message); @@ -278,7 +278,7 @@ PHP_FUNCTION(COM_load) RETURN_FALSE; } - // obtain IDispatch + /* obtain IDispatch */ if (!server_name) { hr=CoCreateInstance(&clsid, NULL, CLSCTX_SERVER, &IID_IDispatch, (void **) &i_dispatch); } else { @@ -447,15 +447,15 @@ static void php_pval_to_variant(pval *pval_arg, VARIANTARG *var_arg) case IS_LONG: case IS_BOOL: if (pval_arg->is_ref == 0) { - var_arg->vt = VT_I4; // assuming 32-bit platform + var_arg->vt = VT_I4; /* assuming 32-bit platform */ var_arg->lVal = pval_arg->value.lval; } else { - var_arg->vt = VT_I4 | VT_BYREF; // assuming 32-bit platform + var_arg->vt = VT_I4 | VT_BYREF; /* assuming 32-bit platform */ var_arg->plVal = &(pval_arg->value.lval); } break; case IS_DOUBLE: - var_arg->vt = VT_R8; // assuming 64-bit double precision + var_arg->vt = VT_R8; /* assuming 64-bit double precision */ var_arg->dblVal = pval_arg->value.dval; break; case IS_STRING: @@ -523,7 +523,7 @@ int do_COM_invoke(IDispatch *i_dispatch, pval *function_name, VARIANTARG *var_re return FAILURE; } -// variant_args = dispparams.rgvarg; +/* variant_args = dispparams.rgvarg; */ for (current_arg=0; current_arg %ld\n", ids, pVarDesc->lpvarValue->lVal); + /*printf("%s -> %ld\n", ids, pVarDesc->lpvarValue->lVal);*/ j++; } TypeInfo->lpVtbl->Release(TypeInfo); diff --git a/ext/snmp/winsnmp.c b/ext/snmp/winsnmp.c index fd8731b7780..45bda9fa9bb 100644 --- a/ext/snmp/winsnmp.c +++ b/ext/snmp/winsnmp.c @@ -201,7 +201,7 @@ void _php3_snmp(INTERNAL_FUNCTION_PARAMETERS, int st) { /* Free the variable bindings that have been allocated.*/ SnmpUtilVarBindListFree(&variableBindings); SnmpUtilOidFree(&root); - } // end if (operation) + } /* end if (operation) */ /* Close SNMP session with the remote agent.*/ diff --git a/ext/standard/info.c b/ext/standard/info.c index c1567e8016c..551d52b7cd6 100644 --- a/ext/standard/info.c +++ b/ext/standard/info.c @@ -145,7 +145,7 @@ PHPAPI void php_print_info(int flag) char *zend_version = get_zend_version(); #ifdef PHP_WIN32 - // Get build numbers for Windows NT or Win95 + /* Get build numbers for Windows NT or Win95 */ if (dwVersion < 0x80000000){ dwBuild = (DWORD)(HIWORD(dwVersion)); snprintf(php_windows_uname,255,"%s %d.%d build %d","Windows NT",dwWindowsMajorVersion,dwWindowsMinorVersion,dwBuild); @@ -554,7 +554,7 @@ void register_phpinfo_constants(INIT_FUNC_ARGS) } -/* {{{ proto void phpinfo(void) +/* {{{ proto void phpinfo([int what]) Output a page of useful information about PHP and the current request */ PHP_FUNCTION(phpinfo) { diff --git a/ext/standard/levenshtein.c b/ext/standard/levenshtein.c index ccb767b6d8f..31699be296f 100644 --- a/ext/standard/levenshtein.c +++ b/ext/standard/levenshtein.c @@ -23,7 +23,8 @@ #include #include "php_string.h" -static int calc_levdist(const char *s1, const char *s2) /* faster, but obfuscated */ +/* faster, but obfuscated, all operations have a cost of 1 */ +static int fastest_levdist(const char *s1, const char *s2) { register char *p1,*p2; register int i,j,n; @@ -68,7 +69,7 @@ static int calc_levdist(const char *s1, const char *s2) /* faster, but obfuscate /* fill initial row */ - n=(*s1!=*s2); + n=1; for(i=0,p1=r;i=255) return -1; + + /* swap if l2 longer than l1 */ + if(l1value.str.val, (*str2)->value.str.val); + break; + + case 5: /* more general version: calc cost by ins/rep/del weights */ + if (zend_get_parameters_ex(5, &str1, &str2, &cost_ins, &cost_rep, &cost_del) == FAILURE) { + WRONG_PARAM_COUNT; + } + convert_to_string_ex(str1); + convert_to_string_ex(str2); + convert_to_long_ex(cost_ins); + convert_to_long_ex(cost_rep); + convert_to_long_ex(cost_del); + + distance = weighted_levdist((*str1)->value.str.val + , (*str2)->value.str.val + , (*cost_ins)->value.lval + , (*cost_rep)->value.lval + , (*cost_del)->value.lval + ); + + break; + + case 3: /* most general version: calc cost by user-supplied function */ + if (zend_get_parameters_ex(3, &str1, &str2, &callback_name) == FAILURE) { + WRONG_PARAM_COUNT; + } + convert_to_string_ex(str1); + convert_to_string_ex(str2); + convert_to_string_ex(callback_name); + + distance = custom_levdist((*str1)->value.str.val + , (*str2)->value.str.val + , (*callback_name)->value.str.lval + ); + break; + + default: WRONG_PARAM_COUNT; - } - convert_to_string_ex(str1); - convert_to_string_ex(str2); - - l = calc_levdist((*str1)->value.str.val, (*str2)->value.str.val); + } - if(l<0) { + if(distance<0) { php_error(E_WARNING,"levenshtein(): argument string(s) too long"); } - - RETURN_LONG(l); + + RETURN_LONG(distance); } /* }}} */ - diff --git a/ext/yaz/php_yaz.c b/ext/yaz/php_yaz.c index 045dff67d1b..e00bfcfd156 100644 --- a/ext/yaz/php_yaz.c +++ b/ext/yaz/php_yaz.c @@ -1296,7 +1296,7 @@ static void retval_grs1 (zval *return_value, Z_GenericRecord *p) eno[level]++; continue; } - // eno[level]++; + /* eno[level]++; */ *tag = '\0'; for (i = 0; i<=level; i++) diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c index 7f4b1060f14..b991f35e3d3 100644 --- a/ext/zlib/zlib.c +++ b/ext/zlib/zlib.c @@ -822,12 +822,14 @@ PHP_FUNCTION(gzuncompress) WRONG_PARAM_COUNT; } convert_to_string_ex(data); - - // zlib::uncompress() wants to know the output data length - // if none was given as a parameter - // we try from input length * 2 up to input length * 2^8 - // doubling it whenever it wasn't big enough - // that should be eneugh for all real life cases + + /* + zlib::uncompress() wants to know the output data length + if none was given as a parameter + we try from input length * 2 up to input length * 2^8 + doubling it whenever it wasn't big enough + that should be eneugh for all real life cases + */ do { length=plength?plength:(*data)->value.str.len*(1< '3') return (SMTP_SERVER_ERROR); @@ -463,7 +466,7 @@ int Ack() } -//******************************************************************** +/********************************************************************* // Name: unsigned long GetAddr (LPSTR szHost) // Input: // Output: @@ -474,7 +477,7 @@ int Ack() // WARNING: gethostbyname() is a blocking function // Author/Date: jcar 20/9/96 // History: -//******************************************************************** +//********************************************************************/ unsigned long GetAddr(LPSTR szHost) { LPHOSTENT lpstHost; diff --git a/win32/sendmail.h b/win32/sendmail.h index 3c426fb2192..38ac29e5eb0 100644 --- a/win32/sendmail.h +++ b/win32/sendmail.h @@ -1,4 +1,4 @@ -#if !defined(sendmail_h) // Sentry, use file only if it's not already included. +#if !defined(sendmail_h) /* Sentry, use file only if it's not already included. */ #define sendmail_h #include @@ -6,8 +6,8 @@ #define MAX_APPNAME_LENGHT 100 #define MAX_ERROR_INDEX 17 #define MIN_ERROR_INDEX 0 -#define MAIL_BUFFER_SIZE (1024*4) // 4k buffer -// Return values +#define MAIL_BUFFER_SIZE (1024*4) /* 4k buffer */ +/* Return values */ #define SUCCESS 0 #define FAILED_TO_PARSE_ARGUMENTS 1 #define FAILED_TO_OPEN_MAILFILE 2 @@ -43,4 +43,4 @@ unsigned long GetAddr(LPSTR szHost); -#endif // sendmail_h +#endif /* sendmail_h */ diff --git a/win32/syslog.h b/win32/syslog.h index 53fd3e67035..420e44b913f 100644 --- a/win32/syslog.h +++ b/win32/syslog.h @@ -65,8 +65,8 @@ extern void closelog(void); extern void openlog(const char *, int, int); -// setlogmask not implemented -//extern int setlogmask (int); +/* setlogmask not implemented */ +/* extern int setlogmask (int); */ extern void syslog(int, const char *, ...); diff --git a/win32/winutil.c b/win32/winutil.c index b7035994e7b..8c3cde86e18 100644 --- a/win32/winutil.c +++ b/win32/winutil.c @@ -12,7 +12,7 @@ char *php_win_err(void) FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), /* Default language */ (LPTSTR) Win_Error_msg, 256, NULL);