src/buffer.c

changeset 1288
b41ad5d9bcbf
parent 1284
b2103354baed
child 1290
4ac889e14211
equal deleted inserted replaced
1287:3a3ffc27813f 1288:b41ad5d9bcbf
145 145
146 size_t opos = npos; 146 size_t opos = npos;
147 npos += offset; 147 npos += offset;
148 148
149 if ((offset > 0 && npos < opos) || (offset < 0 && npos > opos)) { 149 if ((offset > 0 && npos < opos) || (offset < 0 && npos > opos)) {
150 errno = EOVERFLOW; 150 // to be compliant with fseek() specification
151 // we return EINVAL on underflow
152 errno = EINVAL;
151 return -1; 153 return -1;
152 } 154 }
153 155
154 if (npos > buffer->size) { 156 if (npos > buffer->size) {
157 // not compliant with fseek() specification
158 // but this is the better behavior for CxBuffer
159 errno = EINVAL;
155 return -1; 160 return -1;
156 } else { 161 } else {
157 buffer->pos = npos; 162 buffer->pos = npos;
158 return 0; 163 return 0;
159 } 164 }

mercurial