changeset 14:2d7c810a1ac2 default tip

*: misc. cleanup
author Paper <paper@paper.us.eu.org>
date Fri, 03 May 2024 22:40:28 -0400
parents 41b74137e201
children
files .hgignore LICENSE src/datatypes.c src/edl.c src/str.c src/util.c
diffstat 4 files changed, 23 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/src/datatypes.c	Wed Apr 03 20:48:51 2024 -0400
+++ b/src/datatypes.c	Fri May 03 22:40:28 2024 -0400
@@ -21,31 +21,29 @@
 }
 
 size_t EDL_internal_parse_int(const char* input, size_t offset, size_t length, int* int_return) {
+	char* ptr_return = input;
+
 	if (offset > length)
 		return 0;
 
-	{
-		char* ptr_return;
-		*int_return = strtol(&input[offset], &ptr_return, 10);
+	*int_return = strtol(&input[offset], &ptr_return, 10);
 
-		if (!ptr_return)
-			return 0;
-	}
+	if (ptr_return == input)
+		return 0;
 
 	return EDL_internal_append_offset(input, offset, length);
 }
 
 size_t EDL_internal_parse_double(const char* input, size_t offset, size_t length, double* double_return) {
+	char* ptr_return = input;
+
 	if (offset > length)
 		return 0;
 
-	{
-		char* ptr_return;
-		*double_return = strtod(&input[offset], &ptr_return);
+	*double_return = strtod(&input[offset], &ptr_return);
 
-		if (!ptr_return)
-			return 0;
-	}
+	if (ptr_return == input)
+		return 0;
 
 	return EDL_internal_append_offset(input, offset, length);
 }
@@ -79,7 +77,7 @@
 size_t EDL_internal_parse_string(const char* input, size_t offset, size_t length, char** string_return) {
 	size_t start, s_length;
 
-	/* will most definitely break on good filesystems */
+	/* will definitely break on any good filesystem */
 	if (offset > length)
 		return 0;
 
--- a/src/edl.c	Wed Apr 03 20:48:51 2024 -0400
+++ b/src/edl.c	Fri May 03 22:40:28 2024 -0400
@@ -397,32 +397,31 @@
 		"\"Looped\";\"OnRuler\";\"MediaType\";\"FileName\";\"Stream\";\"StreamStart\";\"StreamLength\";"
 		"\"FadeTimeIn\";\"FadeTimeOut\";\"SustainGain\";\"CurveIn\";\"GainIn\";\"CurveOut\";\"GainOut\";"
 		"\"Layer\";\"Color\";\"CurveInR\";\"CurveOutR\":\"PlayPitch\";\"LockPitch\";\"FirstChannel\";\"Channels\"\n";
+	EDL_header header = {0};
+	size_t i;
 
 	EDL_internal_string ret;
 	EDL_internal_string_init(&ret);
 
 	EDL_internal_string_append(&ret, order_str, strlen(order_str));
 
-	{
-		EDL_header header = {0};
-		if (EDL_internal_parse_header(&header, order_str, 0, strlen(order_str)) < 0)
-			return NULL; /* how? */
+	if (EDL_internal_parse_header(&header, order_str, 0, strlen(order_str)) < 0)
+		return NULL; /* how? */
 
-		size_t i;
-		for (i = 0; i < edl->size; i++)
-			EDL_dump_line(&ret, &edl->arr[i], &header);
+	for (i = 0; i < edl->size; i++)
+		EDL_dump_line(&ret, &edl->arr[i], &header);
 
-		EDL_internal_free_header(&header);
-	}
+	EDL_internal_free_header(&header);
 
 	return ret.data;
 }
 
 void EDL_free(EDL* edl) {
 	size_t i;
-	for (i = 0; i < edl->size; i++) {
+
+	for (i = 0; i < edl->size; i++)
 		if (edl->arr[i].filename)
 			free(edl->arr[i].filename);
-	}
+
 	free(edl->arr);
 }
--- a/src/str.c	Wed Apr 03 20:48:51 2024 -0400
+++ b/src/str.c	Fri May 03 22:40:28 2024 -0400
@@ -4,8 +4,7 @@
 #include <string.h>
 
 /* rudimentary string functions so the code in edl.c isn't
- * as painful to read
-*/
+ * as painful to read */
 
 int EDL_internal_string_init(EDL_internal_string* str) {
     if (!str)
--- a/src/util.c	Wed Apr 03 20:48:51 2024 -0400
+++ b/src/util.c	Fri May 03 22:40:28 2024 -0400
@@ -8,10 +8,9 @@
 size_t EDL_internal_strnlen(const char* s, size_t maxlen) {
 	size_t len;
 
-	for (len = 0; len < maxlen; len++, s++) {
+	for (len = 0; len < maxlen; len++, s++)
 		if (!*s)
 			break;
-	}
 
 	return len;
 }