fix token concatenation
[m6w6/ext-psi] / src / token.c
index 95eaf7a6f765db9793198c5226be8233f66364af..df7d2e8592905062cd82ae1025e5fdbc0a5350e8 100644 (file)
@@ -91,13 +91,12 @@ struct psi_token *psi_token_cat(const char *sep, unsigned argc, ...) {
        T->type = PSI_T_NAME;
        T->file = zend_string_copy(T->file);
 
-       for (i = 0; i < argc; ++i) {
-               struct psi_token *arg = va_arg(argv, struct psi_token *);
+       smart_str_append_ex(&text, T->text, 1);
 
-               if (sep_len && text.a) {
-                       smart_str_appendl_ex(&text, sep, sep_len, 1);
-               }
+       for (i = 1; i < argc; ++i) {
+               struct psi_token *arg = va_arg(argv, struct psi_token *);
 
+               smart_str_appendl_ex(&text, sep, sep_len, 1);
                smart_str_append_ex(&text, arg->text, 1);
        }
        va_end(argv);
@@ -173,7 +172,7 @@ static inline uint64_t psi_hash(char *digest_buf, ...)
 uint64_t psi_token_hash(struct psi_token *t, char *digest_buf) {
        char loc_buf[48];
 
-       sprintf(digest_buf, "%u%u", t->line, t->col);
+       sprintf(loc_buf, "%u%u", t->line, t->col);
        return psi_hash(digest_buf, t->file->val, loc_buf, (char *) NULL);
 }