Thread (38 messages) flat view 38 messages, 4 authors, 2016-06-15

Re: mark parsing in fast-import

From: Jörg Sommer <hidden>
Date: 2016-06-15 22:44:31

Hi Shawn,

Shawn O. Pearce schrieb am Sun 20. Apr, 20:26 (-0400):
Jrg Sommer [off-list ref] wrote:
quoted
+static inline int parse_mark(const const char *str, uintmax_t* mark,
Is inline okay?
quoted
+	char **after_mark)
+{
+	if (!str || str[0] != ':' || !isdigit(str[1]))
+		return 1;
+
+	char *am;
Although we conform to mostly C99 style, variables should be
declared at the top of the scope and not after a statement.
Changed.
quoted
 static void cmd_mark(void)
 {
-	if (!prefixcmp(command_buf.buf, "mark :")) {
-		next_mark = strtoumax(command_buf.buf + 6, NULL, 10);
+	uintmax_t mark = 0;
+	char *after_mark = NULL;
+
+	if (!prefixcmp(command_buf.buf, "mark ") &&
+		parse_mark(&command_buf.buf[5], &mark, &after_mark) &&
Hmm.  Shouldn't this be ! parse_mark given that it returns 0
on success and 1 on failure?
Yes, you're right. I've checked some other functions and found this
behaviour. Can I use a different behabiour, i.e. return 0 on failure and
!0 on success?

Bye, Jörg.
-- 
„Wer im Usenet gelesen werden will, sollte leserorientiert schreiben. Wer nur
 für sich schreiben will, dem ist mit einem Tagebuch vielleicht besser
 geholfen. Gelesen zu werden ist kein Recht, sondern ein Privileg.“
     Thore Tams in [off-list ref]

Attachments

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help