src/buffer.c

changeset 1288
b41ad5d9bcbf
parent 1284
b2103354baed
child 1290
4ac889e14211
--- a/src/buffer.c	Sun Apr 13 11:09:05 2025 +0200
+++ b/src/buffer.c	Sun Apr 13 11:54:10 2025 +0200
@@ -147,11 +147,16 @@
     npos += offset;
 
     if ((offset > 0 && npos < opos) || (offset < 0 && npos > opos)) {
-        errno = EOVERFLOW;
+        // to be compliant with fseek() specification
+        // we return EINVAL on underflow
+        errno = EINVAL;
         return -1;
     }
 
     if (npos > buffer->size) {
+        // not compliant with fseek() specification
+        // but this is the better behavior for CxBuffer
+        errno = EINVAL;
         return -1;
     } else {
         buffer->pos = npos;

mercurial