Skip to content

Commit e2e1c84

Browse files
committed
Release k8-0.2.4 (r79)
Skip the first line starting with '#!' for shell compatibility.
1 parent b646aa3 commit e2e1c84

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

k8.cc

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2323
SOFTWARE.
2424
*/
25-
#define K8_VERSION "0.2.3-r67" // known to work with V8-3.16.14
25+
#define K8_VERSION "0.2.4-r79" // known to work with V8-3.16.14
2626

2727
#include <stdlib.h>
2828
#include <stdint.h>
@@ -140,6 +140,15 @@ v8::Handle<v8::String> k8_readfile(const char *name) // Read the entire file. Co
140140
i += read;
141141
}
142142
fclose(file);
143+
144+
if (size > 2 && strncmp(chars, "#!", 2) == 0) { // then skip the "#!" line
145+
int i;
146+
for (i = 0; i < size; ++i)
147+
if (chars[i] == '\n') break;
148+
size -= i + 1;
149+
memmove(chars, &chars[i+1], size);
150+
}
151+
143152
v8::Handle<v8::String> result = v8::String::New(chars, size);
144153
delete[] chars;
145154
return result;

0 commit comments

Comments
 (0)