*/
#include <config.h>
#include <stdio.h>
+#include <stdbool.h>
#include <assert.h>
#include "cdecl.h"
ret += cdecl__advance_(&buf, &n, rc);
rc = cdecl__explain_specs(buf, n, p->qualifiers, CDECL_SPEC_QUAL);
- return ret + cdecl__advance(&buf, &n, rc);
+ return ret + rc;
+}
+
+static bool pointer_needs_space(struct cdecl_declarator *d)
+{
+ assert(d->type == CDECL_DECL_POINTER);
+
+ if (d->u.pointer.qualifiers)
+ return d->child->type != CDECL_DECL_NULL;
+
+ return false;
}
static size_t declare_array(char *buf, size_t n, struct cdecl_array *a)
break;
case CDECL_DECL_POINTER:
rc = declare_pointer(buf, n, &d->u.pointer);
- ret += cdecl__advance_(&buf, &n, rc);
+ if (pointer_needs_space(d))
+ ret += cdecl__advance(&buf, &n, rc);
+ else
+ ret += cdecl__advance_(&buf, &n, rc);
break;
/*
* Arrays and functions are special: since they are postfix,