MCPcopy Create free account
hub / github.com/Tencent/UnLua / mime_global_eol

Function mime_global_eol

Plugins/UnLuaExtensions/LuaSocket/Source/src/mime.cpp:787–808  ·  view source on GitHub ↗

-------------------------------------------------------------------------*\ * 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. \*-------------------------------------------------------------------------*/

Source from the content-addressed store, hash-verified

785* call. 'n' is the new context.
786\*-------------------------------------------------------------------------*/
787static 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.

Callers

nothing calls this directly

Calls 7

luaL_checkintegerFunction · 0.85
luaL_optlstringFunction · 0.85
luaL_buffinitFunction · 0.85
lua_pushnilFunction · 0.85
lua_pushnumberFunction · 0.85
eolprocessFunction · 0.85
luaL_pushresultFunction · 0.85

Tested by

no test coverage detected