erlang各种有用的函数包括一些有用nif封装,还有一些性能测试case。
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

33 lignes
1.0 KiB

  1. -module(utMakeExport).
  2. -export([makeExport/1]).
  3. makeExport(SrcFile) ->
  4. case file:open(SrcFile, [read, binary]) of
  5. {ok, IoDevice} ->
  6. BinStr = doMathEveryLine(IoDevice, "", <<>>),
  7. file:close(IoDevice),
  8. file:write_file("export.config", BinStr);
  9. _ ->
  10. false
  11. end.
  12. doMathEveryLine(IoDevice, Comment, BinStr) ->
  13. case file:read_line(IoDevice) of
  14. {ok, Data} ->
  15. case re:run(Data, "%%") of
  16. {match, _} ->
  17. doMathEveryLine(IoDevice, Data, BinStr);
  18. _ ->
  19. case re:run(Data, "-spec") of
  20. {match, _} ->
  21. {ok, DataFun} = file:read_line(IoDevice),
  22. DataFunStr = binary:replace(DataFun, <<"->\n">>, <<"">>),
  23. doMathEveryLine(IoDevice, "", <<BinStr/binary, DataFunStr/binary, "\t\t\t\t", Comment/binary>>);
  24. _ ->
  25. doMathEveryLine(IoDevice, Comment, BinStr)
  26. end
  27. end;
  28. _ ->
  29. BinStr
  30. end.