-------------------------------------------------------------------------*\ * Converts a string to uniform EOL convention. * A, n = eol(o, B, marker) * A is the converted version of the largest prefix of B that can be * converted unambiguously. 'o' is the context returned by the previous * call. 'n' is the new context. \*-------------------------------------------------------------------------*/
| 785 | * call. 'n' is the new context. |
| 786 | \*-------------------------------------------------------------------------*/ |
| 787 | static int mime_global_eol(lua_State *L) |
| 788 | { |
| 789 | int ctx = (int) luaL_checkinteger(L, 1); |
| 790 | size_t isize = 0; |
| 791 | const char *input = luaL_optlstring(L, 2, NULL, &isize); |
| 792 | const char *last = input + isize; |
| 793 | const char *marker = luaL_optstring(L, 3, CRLF); |
| 794 | luaL_Buffer buffer; |
| 795 | luaL_buffinit(L, &buffer); |
| 796 | /* end of input blackhole */ |
| 797 | if (!input) { |
| 798 | lua_pushnil(L); |
| 799 | lua_pushnumber(L, 0); |
| 800 | return 2; |
| 801 | } |
| 802 | /* process all input */ |
| 803 | while (input < last) |
| 804 | ctx = eolprocess(*input++, ctx, marker, &buffer); |
| 805 | luaL_pushresult(&buffer); |
| 806 | lua_pushnumber(L, ctx); |
| 807 | return 2; |
| 808 | } |
| 809 | |
| 810 | /*-------------------------------------------------------------------------*\ |
| 811 | * Takes one byte and stuff it if needed. |
nothing calls this directly
no test coverage detected